While trying to upgrade to the latest version in trunk (rev. 2537), I have noticed a regression that causes a crash:
in as_compiler.cpp on line 3252 and 3262, GetTypeInfo() may return NULL and it is not check, causing a crash if you try to compile this type of code:
int j=0;
ref@ myRef=j;
So I suggest that the returned pointer is simply checked to NULL above (line 3243):
if (lexpr.type.dataType.IsHandleToAsHandleType() && expr->type.dataType.GetTypeInfo()!=NULL) // FIXME: check that typeInfo is not NULL
{
useHndlAssign = true;
// Make sure the right hand expression is treated as a handle
if (!expr->type.isExplicitHandle && !expr->type.IsNullConstant())
{
// TODO: Clean-up: This code is from CompileExpressionPreOp. Create a reusable function
// Convert the expression to a handle
if (!expr->type.dataType.IsObjectHandle() && !(expr->type.dataType.GetTypeInfo()->flags & asOBJ_ASHANDLE))
{
asCDataType to = expr->type.dataType;
to.MakeHandle(true);
to.MakeReference(true);
to.MakeHandleToConst(expr->type.dataType.IsReadOnly());
ImplicitConversion(expr, to, node, asIC_IMPLICIT_CONV, true, false);
asASSERT(expr->type.dataType.IsObjectHandle());
}
else if (expr->type.dataType.GetTypeInfo()->flags & asOBJ_ASHANDLE)
{
// For the ASHANDLE type we'll simply set the expression as a handle
expr->type.dataType.MakeHandle(true);
}
expr->type.isExplicitHandle = true;
}
}
assigned = CompileOverloadedDualOperator(node, &lexpr, expr, false, &ctx, useHndlAssign);