error_fix.diff (3,410 bytes)
2007-08-23 06:06
The first time I ran fs2_open in Linux it segfaulted.
The simple fix was to move the binary into the data directory.
Firing up the debugger, it was crashing in the Error function.
I tracked it down to some inverted parameters on the call to the error
function. I also noticed a couple other things:
+ memset( &buffer ,... is clobbering the static variables, rather
than clearing the buffer.
+ char * -> const char * on the Error and Warning functions to be
type friendly to vnsprintf
Index: code/globalincs/pstypes.h
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/globalincs/pstypes.h,v
retrieving revision 2.54
diff -u -r2.54 pstypes.h
--- code/globalincs/pstypes.h 22 Mar 2007 22:19:31 -0000 2.54
+++ code/globalincs/pstypes.h 23 Aug 2007 05:33:46 -0000
@@ -606,8 +606,8 @@
//This are defined in MainWin.c
extern void _cdecl WinAssert(char * text,char *filename, int line);
extern void LuaError(struct lua_State *L, char *format=NULL, ...);
-extern void _cdecl Error( char * filename, int line, char * format, ... );
-extern void _cdecl Warning( char * filename, int line, char * format, ... );
+extern void _cdecl Error( char * filename, int line, const char * format, ... );
+extern void _cdecl Warning( char * filename, int line, const char * format, ... );
#include "osapi/outwnd.h"
Index: code/weapon/weapons.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/weapon/weapons.cpp,v
retrieving revision 2.208
diff -u -r2.208 weapons.cpp
--- code/weapon/weapons.cpp 16 Aug 2007 00:45:54 -0000 2.208
+++ code/weapon/weapons.cpp 23 Aug 2007 05:33:47 -0000
@@ -3880,7 +3880,7 @@
// parse weapons.tbl
if ((rval = setjmp(parse_abort)) != 0) {
- Error(LOCATION, "Error parsing '%s'\r\nError code = %i.\r\n", rval, current_weapon_table);
+ Error(LOCATION, "Error parsing '%s'\r\nError code = %i.\r\n", current_weapon_table, rval);
} else {
weapon_reset_info();
Index: code/windows_stub/stubs.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/windows_stub/stubs.cpp,v
retrieving revision 2.35
diff -u -r2.35 stubs.cpp
--- code/windows_stub/stubs.cpp 22 Mar 2007 22:14:57 -0000 2.35
+++ code/windows_stub/stubs.cpp 23 Aug 2007 05:33:47 -0000
@@ -208,15 +208,15 @@
}
// standard warning message
-void Warning( char * filename, int line, char * format, ... )
+void Warning( char * filename, int line, const char * format, ... )
{
#ifndef NDEBUG
va_list args;
int i;
int slen = 0;
- memset( &buffer, 0, sizeof(buffer) );
- memset( &buffer_tmp, 0, sizeof(buffer_tmp) );
+ memset( buffer, 0, sizeof(buffer) );
+ memset( buffer_tmp, 0, sizeof(buffer_tmp) );
va_start(args, format);
vsnprintf(buffer_tmp, sizeof(buffer_tmp) - 1, format, args);
@@ -247,14 +247,14 @@
}
// fatal error message
-void Error( char * filename, int line, char * format, ... )
+void Error( char * filename, int line, const char * format, ... )
{
- va_list args;
int i;
int slen = 0;
+ va_list args;
- memset( &buffer, 0, sizeof(buffer) );
- memset( &buffer_tmp, 0, sizeof(buffer_tmp) );
+ memset( buffer, 0, sizeof(buffer) );
+ memset( buffer_tmp, 0, sizeof(buffer_tmp) );
va_start(args, format);
vsnprintf(buffer_tmp, sizeof(buffer_tmp) - 1, format, args);