Skip to content

Another problem with regexp #142

@mingodad

Description

@mingodad

Hello !
I just found another problem with regexp, this time it's the missing SQRex initialization to compile a pattern.
See fix in SquiLu here mingodad/squilu@95d0ae5

The problem can happen when we try to compile an invalid pattern like:

local re = regexp("[a");

Sometimes we get a runtime error sometimes not depending on what is in memory passing the endo of the string "[a".

On this line:

static SQInteger sqstd_rex_class(SQRex *exp)
{
	SQInteger ret = -1;
	SQInteger first = -1,chain;
	if(*exp->_p == SQREX_SYMBOL_BEGINNING_OF_STRING){
		ret = sqstd_rex_newnode(exp,OP_NCLASS);
		exp->_p++;
	}else ret = sqstd_rex_newnode(exp,OP_CLASS);

	if(*exp->_p == _SC(']')) sqstd_rex_error(exp,_SC("empty class"));
	chain = ret;
	while(*exp->_p != _SC(']') && exp->_p != exp->_eol) { //////Here exp->p was NULL

It seems that the original intent was to check for the '\0' character at the end of the pattern string and the correct code would be:

	while(*exp->_p != _SC(']') && *exp->_p) {

As a side note: Why the author do not apply my pull request #128 ?
It's now more than 5 months for a very simple bug fix. Is Squirrel dead ?
Cheers !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions