🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Version 2.33.0 WIP crash (fix included)

Started by
3 comments, last by WitchLord 5 years, 9 months ago

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);

 

Advertisement

Thanks. I'll have this fixed.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

thanks!

Your change fixes the crash, but in reality the compiler should be giving an error in this case since the right hand expression doesn't support handles.

I've fixed this in revision 2540.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement