From a481bfcc325370c665b9a535f3a5ff4083b42dc7 Mon Sep 17 00:00:00 2001 From: Hoorad Farrokh Date: Mon, 4 Nov 2024 09:09:30 +1300 Subject: [PATCH] Fixed openFile bug --- src/files.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/files.c b/src/files.c index e6231ac..555552e 100644 --- a/src/files.c +++ b/src/files.c @@ -110,16 +110,17 @@ void openFile(char *s) { FILE *file = fopen(s, "r"); if (!file && errno != ENOENT) { die("fopen"); - } + } else if (errno == ENOENT) { - free(curbuf.filename); + free(curbuf.filename); #ifdef _WIN32 - curbuf.filename = _strdup(s); + curbuf.filename = _strdup(s); #else - curbuf.filename = strdup(s); + curbuf.filename = strdup(s); #endif - + return; + } curbuf.numrows = 0; curbuf.cx = 0; curbuf.cy = 0;