From dbcbbb131321068aca9fafb2bd3d30fff7829a80 Mon Sep 17 00:00:00 2001 From: sezero Date: Fri, 24 Aug 2018 21:55:50 +0300 Subject: [PATCH] sst1, sst1InitVoodooFile(): don't leak FILE* pointer in case of failure --- glide2x/cvg/init/parse.c | 4 ++-- glide2x/sst1/init/initvg/parse.c | 16 +++++++++------- glide3x/cvg/init/parse.c | 4 ++-- glide3x/sst1/init/initvg/parse.c | 16 +++++++++------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/glide2x/cvg/init/parse.c b/glide2x/cvg/init/parse.c index df3e917..274bcf7 100644 --- a/glide2x/cvg/init/parse.c +++ b/glide2x/cvg/init/parse.c @@ -247,13 +247,13 @@ FX_ENTRY FxBool FX_CALL sst1InitVoodooFile() if(inCfg) { if(!sst1InitParseFieldCfg(buffer)) { - if(helper) INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[CFG]")); + if(helper) INIT_PRINTF(("ERROR in %s section of .ini file.\n", "[CFG]")); retVal = FXFALSE; break; } } else if(inDac) { if(!sst1InitParseFieldDac(buffer)) { - if(helper) INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[DAC]")); + if(helper) INIT_PRINTF(("ERROR in %s section of .ini file.\n", "[DAC]")); retVal = FXFALSE; break; } diff --git a/glide2x/sst1/init/initvg/parse.c b/glide2x/sst1/init/initvg/parse.c index ccc8790..30949ba 100644 --- a/glide2x/sst1/init/initvg/parse.c +++ b/glide2x/sst1/init/initvg/parse.c @@ -134,22 +134,24 @@ FX_ENTRY FxBool FX_CALL sst1InitVoodooFile() } if(inCfg) { if(!sst1InitParseFieldCfg(buffer)) { - if(helper) - INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[CFG]")); - return(FXFALSE); + tmpPtr = "[CFG]"; + goto _fail; } } else if(inDac) { if(!sst1InitParseFieldDac(buffer)) { - if(helper) - INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[DAC]")); - return(FXFALSE); + tmpPtr = "[DAC]"; + goto _fail; } } } fclose(file); INIT_PRINTF(("INIT: Using .ini file '%s'\n", filename)); - return(FXTRUE); + _fail: + if(helper) + INIT_PRINTF(("ERROR in %s section of .ini file.\n", tmpPtr)); + fclose(file); + return(FXFALSE); #endif } diff --git a/glide3x/cvg/init/parse.c b/glide3x/cvg/init/parse.c index df3e917..274bcf7 100644 --- a/glide3x/cvg/init/parse.c +++ b/glide3x/cvg/init/parse.c @@ -247,13 +247,13 @@ FX_ENTRY FxBool FX_CALL sst1InitVoodooFile() if(inCfg) { if(!sst1InitParseFieldCfg(buffer)) { - if(helper) INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[CFG]")); + if(helper) INIT_PRINTF(("ERROR in %s section of .ini file.\n", "[CFG]")); retVal = FXFALSE; break; } } else if(inDac) { if(!sst1InitParseFieldDac(buffer)) { - if(helper) INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[DAC]")); + if(helper) INIT_PRINTF(("ERROR in %s section of .ini file.\n", "[DAC]")); retVal = FXFALSE; break; } diff --git a/glide3x/sst1/init/initvg/parse.c b/glide3x/sst1/init/initvg/parse.c index ccc8790..30949ba 100644 --- a/glide3x/sst1/init/initvg/parse.c +++ b/glide3x/sst1/init/initvg/parse.c @@ -134,22 +134,24 @@ FX_ENTRY FxBool FX_CALL sst1InitVoodooFile() } if(inCfg) { if(!sst1InitParseFieldCfg(buffer)) { - if(helper) - INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[CFG]")); - return(FXFALSE); + tmpPtr = "[CFG]"; + goto _fail; } } else if(inDac) { if(!sst1InitParseFieldDac(buffer)) { - if(helper) - INIT_PRINTF(("ERROR in %s section of .ini file...\n", "[DAC]")); - return(FXFALSE); + tmpPtr = "[DAC]"; + goto _fail; } } } fclose(file); INIT_PRINTF(("INIT: Using .ini file '%s'\n", filename)); - return(FXTRUE); + _fail: + if(helper) + INIT_PRINTF(("ERROR in %s section of .ini file.\n", tmpPtr)); + fclose(file); + return(FXFALSE); #endif }