saved game memory initialization (dev only)

Qt windowport crashed on startup because a couple alloc() calls in files.c
were not zero'ing out the memory afterward.  This resulted in uninit'd
memory access if there were no saved games.  This bug is in new dev code.
This commit is contained in:
cohrs
2007-02-23 03:44:50 +00:00
parent bbee88dca3
commit c99c3459c8

View File

@@ -1083,6 +1083,7 @@ get_saved_games()
}
if (n > 0) {
result = (char**)alloc((n+1)*sizeof(char*)); /* at most */
(void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*));
if (findfirst((char *)fq_save)) {
j = n = 0;
do {
@@ -1110,6 +1111,7 @@ get_saved_games()
if(!(dir=opendir(fqname("save", SAVEPREFIX, 0))))
return 0;
result = (char**)alloc((n+1)*sizeof(char*)); /* at most */
(void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*));
for (i=0, j=0; i<n; i++) {
int uid;
char name[64]; /* more than PL_NSIZ */