summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kilo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kilo.c b/kilo.c
index c29f626..663e69d 100644
--- a/kilo.c
+++ b/kilo.c
@@ -790,7 +790,9 @@ int editorOpen(char *filename) {
E.dirty = 0;
free(E.filename);
- E.filename = strdup(filename);
+ size_t fnlen = strlen(filename)+1;
+ E.filename = malloc(fnlen);
+ memcpy(E.filename,filename,fnlen);
fp = fopen(filename,"r");
if (!fp) {