Uploaded image for project: 'XWork'
  1. XWork
  2. XW-136

Stack overflow when trying to convert arrays to Integer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0
    • 1.0
    • Type Conversion
    • None
    • Any

    Description

      I've experienced som stack overflows using WebWork2 lately, and found that this has been due to an error in my form handling that uncovered a bug in XWorkBasicConverter. This bug can easily be reproduced by posting a form with a hidden-element associated with the same parameter name as the post action. E.g:

      <form action="someAction?id=1>
      <input type="hidden" name="id" value="2"/>
      </form>

      If someAction has setId(Integer id), then ParametersInterceptor will try to convert the id parameter ([1, 2]) into an Integer using XWorkBasicConverter. The interesting lines in XWorkBasicConverter are:

      – snip —
      if ((array != null) && (array.length == 1)) {
      value = array[0];
      }

      // let's try to convert the first element only
      result = this.convertValue(context, o, member, s, value, toType);

      – snip —

      Since the array is of size 2, value is not set to array[0] and the last line is not executed as the comment indicates. It just calls itself recursively with the same parameters each time leading to a stack overflow.

      Attachments

        Issue Links

          Activity

            People

              jcarreira Jason Carreira
              daggerrz Dag Liodden
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: