CD-ROM Image: close log before closing the file, fixes segmentation fault on image unload.
This commit is contained in:
@@ -357,18 +357,15 @@ index_file_init(const uint8_t id, const char *filename, int *error, int *is_viso
|
|||||||
*is_viso = 1;
|
*is_viso = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
index_file_close(track_index_t *idx)
|
index_file_close(track_index_t *idx)
|
||||||
{
|
{
|
||||||
if ((idx == NULL) || (idx->file == NULL) ||
|
if ((idx == NULL) || (idx->file == NULL))
|
||||||
(idx->file->close == NULL))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
idx->file->close(idx->file);
|
|
||||||
|
|
||||||
image_log(idx->file->log, "Log closed\n");
|
image_log(idx->file->log, "Log closed\n");
|
||||||
|
|
||||||
if (idx->file->log != NULL) {
|
if (idx->file->log != NULL) {
|
||||||
@@ -376,6 +373,9 @@ index_file_close(track_index_t *idx)
|
|||||||
idx->file->log = NULL;
|
idx->file->log = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (idx->file->close != NULL)
|
||||||
|
idx->file->close(idx->file);
|
||||||
|
|
||||||
idx->file = NULL;
|
idx->file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@ image_cue_get_buffer(char *str, char **line, const int up)
|
|||||||
static int
|
static int
|
||||||
image_cue_get_keyword(char **dest, char **line)
|
image_cue_get_keyword(char **dest, char **line)
|
||||||
{
|
{
|
||||||
int success = image_cue_get_buffer(temp_keyword, line, 1);
|
const int success = image_cue_get_buffer(temp_keyword, line, 1);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
*dest = temp_keyword;
|
*dest = temp_keyword;
|
||||||
@@ -1676,16 +1676,16 @@ image_clear_tracks(cd_image_t *img)
|
|||||||
|
|
||||||
if (((cur->point >= 1) && (cur->point <= 99)) ||
|
if (((cur->point >= 1) && (cur->point <= 99)) ||
|
||||||
(cur->point == 0xa2)) for (int j = 0; j < 3; j++) {
|
(cur->point == 0xa2)) for (int j = 0; j < 3; j++) {
|
||||||
idx = &(cur->idx[j]);
|
idx = &(cur->idx[j]);
|
||||||
/* Make sure we do not attempt to close a NULL file. */
|
/* Make sure we do not attempt to close a NULL file. */
|
||||||
if ((idx->file != NULL) && (idx->type == INDEX_NORMAL)) {
|
if ((idx->file != NULL) && (idx->type == INDEX_NORMAL)) {
|
||||||
if (idx->file != last) {
|
if (idx->file != last) {
|
||||||
last = idx->file;
|
last = idx->file;
|
||||||
index_file_close(idx);
|
index_file_close(idx);
|
||||||
} else
|
} else
|
||||||
idx->file = NULL;
|
idx->file = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now free the array. */
|
/* Now free the array. */
|
||||||
@@ -1905,8 +1905,8 @@ image_get_track_type(const void *local, const uint32_t sector)
|
|||||||
const track_t *nt = &(img->tracks[i + 1]);
|
const track_t *nt = &(img->tracks[i + 1]);
|
||||||
|
|
||||||
if (ct->point == 0xa0) {
|
if (ct->point == 0xa0) {
|
||||||
uint8_t first = (ct->idx[1].start / 75 / 60);
|
const uint8_t first = (ct->idx[1].start / 75 / 60);
|
||||||
uint8_t last = (nt->idx[1].start / 75 / 60);
|
const uint8_t last = (nt->idx[1].start / 75 / 60);
|
||||||
|
|
||||||
if ((trk->point >= first) && (trk->point <= last)) {
|
if ((trk->point >= first) && (trk->point <= last)) {
|
||||||
ret = (ct->idx[1].start / 75) % 60;
|
ret = (ct->idx[1].start / 75) % 60;
|
||||||
|
|||||||
Reference in New Issue
Block a user