summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2023-01-12 16:34:28 -0700
committercflip <cflip@cflip.net>2023-01-12 16:34:28 -0700
commit7964e549ff3889455ce1d1a87b47ab1b0adb722c (patch)
tree2b028151d84f6b09bad43a1bb86134a1143abf00
parent6c2d533798a3f3d56082dc9a72887fe05672bb5c (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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/file.c b/file.c
index f432b1d..680f8ae 100644
--- a/file.c
+++ b/file.c
@@ -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);