From c78193b74f09e91298142b45860dcbd519332c43 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Sun, 30 Apr 2017 03:28:45 +0100 Subject: [PATCH] fix 'n' overwrite option crashing + no return in ProcessFile ProcessFile always returns 1 though, so Errors is always gonna be 0... meh --- hmmlconv/hmmlconv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hmmlconv/hmmlconv.c b/hmmlconv/hmmlconv.c index 6ca3941..e605bc9 100644 --- a/hmmlconv/hmmlconv.c +++ b/hmmlconv/hmmlconv.c @@ -400,6 +400,8 @@ int ProcessFile(char *InFileName, FILE *InFile, FILE *OutFile) Done: fputs("[/video]\n", OutFile); free(Contents); + + return 1; } int main(int ArgC, char **Args) @@ -442,7 +444,7 @@ int main(int ArgC, char **Args) char OutNameBuf[strlen(OutDirName) + strlen(FileNameBase) + 7]; sprintf(OutNameBuf, "%s/%s.hmml", OutDirName, FileNameBase); - FILE *OutFile; + FILE *OutFile = NULL; { int OpenFlags = O_CREAT | O_EXCL | O_WRONLY; @@ -479,7 +481,7 @@ OpenOutput:; fprintf(stderr, "Error opening %s: %s\n", Args[i], strerror(errno)); } - if(!InFile || !OutFile || !ProcessFile(FileNameBase, InFile, OutFile)) + if(InFile && OutFile && !ProcessFile(FileNameBase, InFile, OutFile)) { ++Errors; }