[Fix] Fixed a possible double free due to uninitialised memory.
This commit is contained in:
parent
5d34065512
commit
8ded27ec20
@ -1111,17 +1111,18 @@ static void misn_genList(unsigned int wid, int first) {
|
|||||||
window_destroyWidget(wid, "lstMission");
|
window_destroyWidget(wid, "lstMission");
|
||||||
|
|
||||||
/* List. */
|
/* List. */
|
||||||
|
j = 1; /* Make sure we don't accidently free the memory twise. */
|
||||||
if(mission_ncomputer > 0) {
|
if(mission_ncomputer > 0) {
|
||||||
/* there are missions. */
|
/* there are missions. */
|
||||||
misn_names = malloc(sizeof(char*) * mission_ncomputer);
|
misn_names = malloc(sizeof(char*) * mission_ncomputer);
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i = 0; i < mission_ncomputer; i++)
|
for(i = 0; i < mission_ncomputer; i++)
|
||||||
if(mission_computer[i].title)
|
if(mission_computer[i].title != NULL)
|
||||||
misn_names[j++] = strdup(mission_computer[i].title);
|
misn_names[j++] = strdup(mission_computer[i].title);
|
||||||
}
|
}
|
||||||
if((mission_ncomputer == 0) || (j == 0)) {
|
if((mission_ncomputer==0) || (j == 0)) { /* No missions. */
|
||||||
/* No missions. */
|
if(j == 0)
|
||||||
if(j == 0) free(misn_names);
|
free(misn_names);
|
||||||
misn_names = malloc(sizeof(char*));
|
misn_names = malloc(sizeof(char*));
|
||||||
misn_names[0] = strdup("No Missions");
|
misn_names[0] = strdup("No Missions");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user