Bug Report 2001/07/16-v1.0b25-br01

[forum ]
[Win98 Setup Bug]
Bug Report id=2001/07/16-v1.0b25-br01
Affected versions:v1.0b25 all variations

Bug Description

The interpreter reports syntax error for all constant definitions where the constant value is positive and is written with a plus sign starting it. For example:
const C= +1

reports syntax error. The interpreter process causes segmentation fault for invalid constant declarations. For example the following program causes the interpreter crash:
const C=then
print C

Bug Reason, What Causes the Bug

There are programming bugs in the code that defines constants. It allows any lexical token to be assigned to a constant and later usage of constants assumes that the token represents a number or a string and crashes.


Until the next available release the source code has to be modified and recompiled. In expression.c search the line
        if( LexemeType == LEX_T_NSYMBOL && ( LexemeCode == CMD_MINUS ||
LexemeCode == CMD_MINUS ) ){

and alter it to
        if( LexemeType == LEX_T_NSYMBOL && ( LexemeCode == CMD_MINUS ||
LexemeCode == CMD_PLUS ) ){

A few lines later search for
        pConstValue = pEx->pLex->pLexCurrentLexeme;

and insert lines so that the check is done:
        if(  LexemeType != LEX_T_DOUBLE && 
             LexemeType != LEX_T_LONG && 
             LexemeType != LEX_T_STRING )ABORT;
        pConstValue = pEx->pLex->pLexCurrentLexeme;

After the modification recompile the code.

Bug Workaround Until Solution is Available

In case you can not alter and recompile the code avoid using signed positive constants. Use the implicit positive value, like:
const C=1

Avoid programs that make the interpreter crash in production environment.



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