[MAIN] [News] [Intro] [Features] [Download] [Installation] [Support] [Support+] [Docu] [Tutorial] [Bugs] [forum ] [wiki] [Mirror] [Authors] [Future] [License] [Win98 Setup Bug] [Subscribe] |
Bug DescriptionThe programfor i = "0" to 9 print i next ifails to run and crashes the interpreter process. Bug Reason, What Causes the BugThe 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.SolutionIn 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 AvailableDo not use strings as FOR loop initialization constants.AcknowledgementMitchell Greess [m.greess@solutions-atlantic.com] provided this bug report along with the solution. Thanks. |