fixes for memory leaks and out of bounds memory access found by ASAN or gcc -flto

This commit is contained in:
kub 2020-12-12 14:57:56 +01:00
parent bb70cc6e66
commit a20300bf1e
8 changed files with 27 additions and 12 deletions

View file

@ -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)