(svn r12110) [NoAI] -Fix [FS#1746]: possible segmentation fault when trying to load another script file noai
authorsmatz
Mon, 11 Feb 2008 14:20:41 +0000
branchnoai
changeset 9725 a73b33a966be
parent 9724 b39bc69bb2f2
child 9726 f80f1d0bae90
(svn r12110) [NoAI] -Fix [FS#1746]: possible segmentation fault when trying to load another script file
src/squirrel_std.cpp
--- a/src/squirrel_std.cpp	Sun Feb 03 20:17:54 2008 +0000
+++ b/src/squirrel_std.cpp	Mon Feb 11 14:20:41 2008 +0000
@@ -5,6 +5,7 @@
 #include "debug.h"
 #include "squirrel.hpp"
 #include "squirrel_std.hpp"
+#include "core/alloc_func.hpp"
 
 /* abs() is normally defined to myabs(), which we don't want in this file */
 #undef abs
@@ -41,7 +42,9 @@
 		*s++;
 		*s = '\0';
 	}
-	/* And now we concat, so we are relative from the current script */
+	/* And now we concat, so we are relative from the current script
+	 * First, we have to make sure we have enough space for the full path */
+	real_filename = ReallocT(real_filename, scstrlen(real_filename) + scstrlen(filename) + 1);
 	scstrcat(real_filename, filename);
 
 	/* Make sure we are in the root-table, so everything is included in the root-level */