Skip to content

Commit b3e9165

Browse files
author
Noam Preil
committed
Fix memory corruption in handle_map
1 parent 74e704b commit b3e9165

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

assembler/directives.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ int handle_list(struct assembler_state *state, char **argv, int argc) {
970970

971971
int handle_map(struct assembler_state *state, char **argv, int argc) {
972972
// .map filename, lineno, code
973-
strcpy(((source_map_t *)stack_peek(state->source_map_stack))->file_name, argv[0]);
974-
add_source_map((source_map_t *)stack_peek(state->source_map_stack),
973+
free(((source_map_t *)stack_peek(state->source_map_stack))->file_name);
974+
((source_map_t*)stack_peek(state->source_map_stack))->file_name = strdup(argv[0]); add_source_map((source_map_t *)stack_peek(state->source_map_stack),
975975
atoi(argv[1]), argv[2], state->PC, 1); // TODO: figure out actual length
976976
return 1;
977977
}

0 commit comments

Comments
 (0)