diff --git a/main.c b/main.c index 31421c3..67558f9 100644 --- a/main.c +++ b/main.c @@ -98,11 +98,11 @@ unigi_ext_type_sound_sample * unigi_ext_sound_open(char * path) { unigi_ext_type_sound_sample * sample = malloc(sizeof(unigi_ext_type_sound_sample)); if (sample == NULL) { goto fail; } int fd = open(path,O_RDONLY); - if (fd == -1) { goto fail; } + if (fd == -1) { goto fail_sample; } size_t size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); uint8_t * data = malloc(size); - if (data == NULL) { goto fail_sample; } + if (data == NULL) { goto fail_file; } if (read(fd,data,size) != size) { goto fail_data; } close(fd); sample->size = size; @@ -111,9 +111,10 @@ unigi_ext_type_sound_sample * unigi_ext_sound_open(char * path) { fail_data:; free(data); + fail_file:; + close(fd); fail_sample:; free(sample); - close(fd); fail:; return NULL; }