diff options
author | cflip <cflip@cflip.net> | 2023-01-12 16:34:28 -0700 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2023-01-12 16:34:28 -0700 |
commit | 7964e549ff3889455ce1d1a87b47ab1b0adb722c (patch) | |
tree | 2b028151d84f6b09bad43a1bb86134a1143abf00 | |
parent | 6c2d533798a3f3d56082dc9a72887fe05672bb5c (diff) |
Replace call to strdup() with equivalent behaviour
This was causing the editor to crash on startup when opening a file from
the command line.
-rw-r--r-- | file.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -37,7 +37,9 @@ char* editor_rows_to_string(struct editor_state* editor, int* buffer_length) void editor_open(struct editor_state* editor, char* filename) { free(editor->filename); - editor->filename = strdup(filename); + size_t filename_len = strlen(filename); + editor->filename = malloc(filename_len); + memcpy(editor->filename, filename, filename_len); editor_select_syntax_highlight(editor); |