pull request #1007 - avoid free(emptystr)
Pull request from argrath: save_luadata() sets 'lua_data' to 'emptystr' if the fetch variables routine returns Null, and later passes 'lua_data' to free() unconditionally. Freeing 'emptystr' won't work and might crash (if the fetch routine ever returned Null, which might never happen). Fixes #1007
This commit is contained in:
@@ -1206,7 +1206,7 @@ save_luadata(NHFILE *nhfp)
|
||||
char *lua_data = get_nh_lua_variables(); /* note: '\0' terminated */
|
||||
|
||||
if (!lua_data)
|
||||
lua_data = emptystr;
|
||||
lua_data = dupstr(emptystr);
|
||||
lua_data_len = Strlen(lua_data) + 1; /* +1: include the terminator */
|
||||
bwrite(nhfp->fd, (genericptr_t) &lua_data_len,
|
||||
(unsigned) sizeof lua_data_len);
|
||||
|
||||
Reference in New Issue
Block a user