Skip to content

Commit

Permalink
Merge pull request #1 from francois-berder/master
Browse files Browse the repository at this point in the history
Fix resource leaks
  • Loading branch information
superzazu authored Dec 1, 2019
2 parents 86e9895 + cd08060 commit c46a000
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions m6502_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ static int load_file_into_memory(const char* filename, uint16_t addr) {

if (file_size + addr > MEMORY_SIZE) {
fprintf(stderr, "error: file %s can't fit in memory.\n", filename);
fclose(f);
return 1;
}

// copying the bytes in the memory:
size_t result = fread(&memory[addr], sizeof(uint8_t), file_size, f);
if (result != file_size) {
fprintf(stderr, "error: while reading file '%s'\n", filename);
fclose(f);
return 1;
}

Expand Down

0 comments on commit c46a000

Please sign in to comment.