CD-ROM: Only do the lead out processing on REM SESSION command if session is greater than 1, fixes crashes with arithmetic exception (ie. division by zero).

This commit is contained in:
OBattler
2025-08-29 23:39:13 +02:00
parent 941d0850de
commit d287b81054

View File

@@ -1743,28 +1743,27 @@ image_load_cue(cd_image_t *img, const char *cuefile)
image_log(img->log, " [LEAD-OUT] Initialization %s\n",
success ? "successful" : "failed");
} else if (!strcmp(command, "SESSION")) {
if (!lo_cmd) {
ct = &(img->tracks[lead[2]]);
/*
Mark it this way so file pointers on it are not
going to be adjusted.
*/
last_t = -1;
ct->sector_size = last;
ci = &(ct->idx[1]);
ci->type = INDEX_ZERO;
ci->file = tf;
ci->file_start = 0;
ci->file_length = 0;
ci->length = (2 * 60 * 75) + (30 * 75);
image_log(img->log, " [LEAD-OUT] Initialization successful\n");
}
lo_cmd = 0;
session = image_cue_get_number(&space);
if (session > 1) {
if (!lo_cmd) {
ct = &(img->tracks[lead[2]]);
/*
Mark it this way so file pointers on it are not
going to be adjusted.
*/
last_t = -1;
ct->sector_size = last;
ci = &(ct->idx[1]);
ci->type = INDEX_ZERO;
ci->file = tf;
ci->file_start = 0;
ci->file_length = 0;
ci->length = (2 * 60 * 75) + (30 * 75);
image_log(img->log, " [LEAD-OUT] Initialization successful\n");
}
ct = image_insert_track(img, session - 1, 0xb0);
/*
Mark it this way so file pointers on it are not
@@ -1801,6 +1800,8 @@ image_load_cue(cd_image_t *img, const char *cuefile)
}
}
lo_cmd = 0;
image_log(img->log, " [SESSION ] Initialization successful\n");
}
}