mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
fixes for memory leaks and out of bounds memory access found by ASAN or gcc -flto
This commit is contained in:
parent
bb70cc6e66
commit
a20300bf1e
8 changed files with 27 additions and 12 deletions
|
@ -941,6 +941,7 @@ void cdd_process(void)
|
|||
case 0x01: /* Current Track Relative Time (MM:SS:FF) */
|
||||
{
|
||||
int lba = cdd.lba - cdd.toc.tracks[cdd.index].start;
|
||||
if (lba < 0) lba = 0;
|
||||
set_reg16(0x38, (cdd.status << 8) | 0x01);
|
||||
set_reg16(0x3a, lut_BCD_16[(lba/75)/60]);
|
||||
set_reg16(0x3c, lut_BCD_16[(lba/75)%60]);
|
||||
|
|
|
@ -71,11 +71,11 @@ static int get_ext(const char *fname, char ext[4],
|
|||
{
|
||||
int len, pos = 0;
|
||||
|
||||
len = strlen(fname);
|
||||
if (len >= 3)
|
||||
pos = len - 3;
|
||||
len = strrchr(fname, '.') - fname;
|
||||
if (len > 0)
|
||||
pos = len;
|
||||
|
||||
strcpy(ext, fname + pos);
|
||||
strcpy(ext, fname + pos + 1);
|
||||
|
||||
if (base != NULL) {
|
||||
if (pos + 1 < base_size)
|
||||
|
@ -153,9 +153,8 @@ cue_data_t *cue_parse(const char *fname)
|
|||
|
||||
// the basename of cuefile, no path
|
||||
snprintf(cue_base, sizeof(cue_base), "%s", current_filep);
|
||||
p = cue_base + strlen(cue_base);
|
||||
if (p - 3 >= cue_base)
|
||||
p[-3] = 0;
|
||||
p = strrchr(cue_base, '.');
|
||||
if (p) p[1] = '\0';
|
||||
|
||||
data = calloc(1, sizeof(*data) + count_alloc * sizeof(cue_track));
|
||||
if (data == NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue