Bug Report 2001/10/11-v1.0b26-br01


[MAIN]
[News]
[Intro]
[Features]
[Download]
[Installation]
[Support]
[Support+]
[Docu]
[Tutorial]
[Bugs]
[forum ]
[wiki]
[Mirror]
[Authors]
[Future]
[License]
[Win98 Setup Bug]
[Subscribe]
Bug Report id=2001/10/11-v1.0b26-br01
Affected versions:v1.0b26
Severity:Severe

Bug Description

The program
for i = "0" to 9
 print i
next i

fails to run and crashes the interpreter process.

Bug Reason, What Causes the Bug

The code implementing the loop FOR assigns a variable to the loop variable but this value is converted to immortal before the conversion from string to integer takes place. When the execution of the statement is finished the mortal variables are released and the loop variable holds a value, which is already released.

Solution

In the source file commands/while.c implementing all the loop commands the function COMMAND(FOR) has to be altered. The original code fragment:
  NEXTPARAMETER;
  StartExpressionResult = EVALUATEEXPRESSION(PARAMETERNODE);
  ASSERTOKE;
  if( StartExpressionResult )IMMORTALIZE(StartExpressionResult);
  if( StartExpressionResult && TYPE(StartExpressionResult) == VTYPE_STRING ){
        if( ISSTRINGINTEGER(StartExpressionResult) )
          StartExpressionResult = CONVERT2LONG(StartExpressionResult);
        else
          StartExpressionResult = CONVERT2DOUBLE(StartExpressionResult);

    }


has to be changed to
  NEXTPARAMETER;
  StartExpressionResult = EVALUATEEXPRESSION(PARAMETERNODE);
  ASSERTOKE;

  if( StartExpressionResult && TYPE(StartExpressionResult) == VTYPE_STRING ){
        if( ISSTRINGINTEGER(StartExpressionResult) )
          StartExpressionResult = CONVERT2LONG(StartExpressionResult);
        else
          StartExpressionResult = CONVERT2DOUBLE(StartExpressionResult);
    }

  if( StartExpressionResult )IMMORTALIZE(StartExpressionResult);

The bug will be corrected in the next release build of ScriptBasic.

Bug Workaround Until Solution is Available

Do not use strings as FOR loop initialization constants.

Acknowledgement

Mitchell Greess [m.greess@solutions-atlantic.com] provided this bug report along with the solution. Thanks.

This page was generated January 28, 2010 9:58:42