From 48217aee7fb123a753e326cb8e761e14923fa47c Mon Sep 17 00:00:00 2001 From: Erwin Waterlander Date: Sat, 1 Dec 2018 16:52:34 +0100 Subject: [PATCH 09/11] Fixed issues reported by Coverity Scan See https://sourceforge.net/p/dos2unix/bugs/18/ --- dos2unix/ChangeLog.txt | 4 ++++ dos2unix/README.txt | 2 ++ dos2unix/common.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git dos2unix/common.c dos2unix/common.c index d46db7e..689dc4e 100644 --- dos2unix/common.c +++ dos2unix/common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2017 Erwin Waterlander + * Copyright (C) 2009-2018 Erwin Waterlander * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -983,6 +983,7 @@ FILE* MakeTempFileFrom(const char *OutFN, char **fname_ret) *fname_ret = fname_str; free(cpy); + cpy = NULL; #ifdef NO_MKSTEMP if ((name = d2u_mktemp(fname_str)) == NULL) @@ -1001,6 +1002,10 @@ FILE* MakeTempFileFrom(const char *OutFN, char **fname_ret) return (fp); make_failed: + if (cpy) { + free(cpy); + cpy = NULL; + } free(*fname_ret); *fname_ret = NULL; return NULL; @@ -1978,7 +1983,7 @@ void printInfo(CFlag *ipFlag, const char *filename, int bomtype, unsigned int lb D2U_UTF8_FPRINTF(stdout, "FILE"); } if (ipFlag->file_info & INFO_PRINT0) - fputc(0, stdout); + (void) fputc(0, stdout); else D2U_UTF8_FPRINTF(stdout, "\n"); header_done = 1; @@ -2009,7 +2014,7 @@ void printInfo(CFlag *ipFlag, const char *filename, int bomtype, unsigned int lb D2U_UTF8_FPRINTF(stdout, "%s",ptr); } if (ipFlag->file_info & INFO_PRINT0) - fputc(0, stdout); + (void) fputc(0, stdout); else D2U_UTF8_FPRINTF(stdout, "\n"); } -- 2.19.1