(svn r12113) [NoAI] -Fix: memory leak in require() noai
authorglx
Mon, 11 Feb 2008 18:08:09 +0000
branchnoai
changeset 9727 a5fdea13a991
parent 9726 f80f1d0bae90
child 9728 d7bd32dc6c59
(svn r12113) [NoAI] -Fix: memory leak in require()
src/squirrel_std.cpp
--- a/src/squirrel_std.cpp	Mon Feb 11 17:50:47 2008 +0000
+++ b/src/squirrel_std.cpp	Mon Feb 11 18:08:09 2008 +0000
@@ -49,15 +49,19 @@
 
 	/* Make sure we are in the root-table, so everything is included in the root-level */
 	sq_pushroottable(vm);
+
+	SQInteger ret = 0;
+
 	/* Compile and load the file */
 	if (!SQ_SUCCEEDED(sqstd_dofile(vm, real_filename, SQFalse, SQTrue))) {
 		DEBUG(misc, 0, "[squirrel] Failed to compile '%s'", filename);
-		sq_settop(vm, top);
-		return SQ_ERROR;
+		ret = SQ_ERROR;
 	}
 	/* Reset the top, so the stack stays correct */
 	sq_settop(vm, top);
-	return 0;
+	free(real_filename);
+
+	return ret;
 }
 
 void squirrel_register_global_std(Squirrel *engine)