Fix resource leaks in bin2s.c

Fix resource leaks in bin2s.c
This commit is contained in:
ryancaicse
2022-02-07 15:18:17 +08:00
committed by GitHub
parent a78df04996
commit 72f3714247

View File

@@ -40,11 +40,13 @@ int main(int argc, char *argv[])
buffer = malloc(fd_size);
if(buffer == NULL) {
printf("Failed to allocate memory.\n");
fclose(source);
return 1;
}
if(fread(buffer,1,fd_size,source) != fd_size) {
printf("Failed to read file.\n");
fclose(source);
return 1;
}
fclose(source);