Commit 4b841ecd authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Fix memory leak when incompressable

Don't leak longs and shorts when skipping compression.
Found by cppcheck static analysis.

Version 5.17. Tagged as 'squeeze-5_17'
parent 017f31a5
/* (5.16) /* (5.17)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 5.16 #define Module_MajorVersion_CMHG 5.17
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 08 May 2015 #define Module_Date_CMHG 19 Aug 2018
#define Module_MajorVersion "5.16" #define Module_MajorVersion "5.17"
#define Module_Version 516 #define Module_Version 517
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "08 May 2015" #define Module_Date "19 Aug 2018"
#define Module_ApplicationDate "08-May-15" #define Module_ApplicationDate "19-Aug-18"
#define Module_ComponentName "squeeze" #define Module_ComponentName "squeeze"
#define Module_ComponentPath "castle/RiscOS/Tools/Sources/squeeze" #define Module_ComponentPath "castle/RiscOS/Tools/Sources/squeeze"
#define Module_FullVersion "5.16" #define Module_FullVersion "5.17"
#define Module_HelpVersion "5.16 (08 May 2015)" #define Module_HelpVersion "5.17 (19 Aug 2018)"
#define Module_LibraryVersionInfo "5:16" #define Module_LibraryVersionInfo "5:17"
...@@ -263,7 +263,7 @@ static char *heaplwm; ...@@ -263,7 +263,7 @@ static char *heaplwm;
static char *heaphwm; static char *heaphwm;
#endif #endif
static void *xalloc(int bytes, char *what) static void *xalloc(int bytes, const char *what)
{ void *p = malloc(bytes); { void *p = malloc(bytes);
if (p == NULL) err_fail("no more room"); if (p == NULL) err_fail("no more room");
/* if ((int)p < 0) err_fail("storage corruption (%d)", (int)p); */ /* if ((int)p < 0) err_fail("storage corruption (%d)", (int)p); */
...@@ -700,7 +700,11 @@ static char *compresscode(word *code, int size, int execoffset) ...@@ -700,7 +700,11 @@ static char *compresscode(word *code, int size, int execoffset)
(nliterals * 100) / nwords); (nliterals * 100) / nwords);
if (guess > (9*size)/10) { /* not much squeeze to be had */ if (guess > (9*size)/10) { /* not much squeeze to be had */
if ((!force) || (guess > size)) return(NULL); if ((!force) || (guess > size)) {
xfree(shorts);
xfree(longs);
return(NULL);
}
} }
/* /*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment