Skip to content

Commit 4b5f782

Browse files
authored
iOS: Fix crash during scanning (#17489)
1 parent fd8ba55 commit 4b5f782

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tasks/task_database_cue.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,19 @@ int detect_ps2_game(intfstream_t *fd, char *s, size_t len, const char *filename)
279279
#define DISC_DATA_SIZE_PS2 0x84000
280280
int pos;
281281
char raw_game_id[50];
282-
char disc_data[DISC_DATA_SIZE_PS2];
282+
char *disc_data;
283283

284284
/* Load data into buffer and use pointers */
285285
if (intfstream_seek(fd, 0, SEEK_SET) < 0)
286286
return false;
287287

288+
disc_data = malloc(DISC_DATA_SIZE_PS2);
289+
288290
if (intfstream_read(fd, disc_data, DISC_DATA_SIZE_PS2) <= 0)
291+
{
292+
free(disc_data);
289293
return false;
294+
}
290295

291296
disc_data[DISC_DATA_SIZE_PS2 - 1] = '\0';
292297

@@ -373,6 +378,7 @@ int detect_ps2_game(intfstream_t *fd, char *s, size_t len, const char *filename)
373378

374379
string_remove_all_whitespace(s, raw_game_id);
375380
cue_append_multi_disc_suffix(s, filename);
381+
free(disc_data);
376382
return true;
377383
}
378384
}
@@ -390,6 +396,7 @@ int detect_ps2_game(intfstream_t *fd, char *s, size_t len, const char *filename)
390396
s[9 ] = 'X';
391397
s[10] = '\0';
392398
cue_append_multi_disc_suffix(s, filename);
399+
free(disc_data);
393400
return false;
394401
}
395402

0 commit comments

Comments
 (0)