From 887d955854789aa76f75fc83fa929600e3922265 Mon Sep 17 00:00:00 2001 From: Robert Sprowson <rsprowson@gitlab.riscosopen.org> Date: Sun, 21 Jan 2018 09:33:13 +0000 Subject: [PATCH] Fix ideograph range check and a couple of resource leaks unicdata.c: condition changed to match unictype_is_ideograph() in UnicodeLib keygen.c: free kb keyconvert.c: free memory and close files on exit (the C environment would do this anyway, but this makes it explicit) Picked up by static analysis https://www.riscosopen.org/forum/forums/4/topics/9503#posts-72623 Version 0.99. Tagged as 'IntKey-0_99' --- VersionASM | 12 ++++++------ VersionNum | 20 ++++++++++---------- c/keyconvert | 12 +++++++++--- c/keygen | 1 + c/unicdata | 2 +- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/VersionASM b/VersionASM index 6c5398b..9652932 100644 --- a/VersionASM +++ b/VersionASM @@ -11,13 +11,13 @@ GBLS Module_HelpVersion GBLS Module_ComponentName GBLS Module_ComponentPath -Module_MajorVersion SETS "0.98" -Module_Version SETA 98 +Module_MajorVersion SETS "0.99" +Module_Version SETA 99 Module_MinorVersion SETS "" -Module_Date SETS "22 Nov 2014" -Module_ApplicationDate SETS "22-Nov-14" +Module_Date SETS "21 Jan 2018" +Module_ApplicationDate SETS "21-Jan-18" Module_ComponentName SETS "IntKey" Module_ComponentPath SETS "castle/RiscOS/Sources/Internat/IntKey" -Module_FullVersion SETS "0.98" -Module_HelpVersion SETS "0.98 (22 Nov 2014)" +Module_FullVersion SETS "0.99" +Module_HelpVersion SETS "0.99 (21 Jan 2018)" END diff --git a/VersionNum b/VersionNum index 24745d0..9a18ca8 100644 --- a/VersionNum +++ b/VersionNum @@ -1,23 +1,23 @@ -/* (0.98) +/* (0.99) * * This file is automatically maintained by srccommit, do not edit manually. * Last processed by srccommit version: 1.1. * */ -#define Module_MajorVersion_CMHG 0.98 +#define Module_MajorVersion_CMHG 0.99 #define Module_MinorVersion_CMHG -#define Module_Date_CMHG 22 Nov 2014 +#define Module_Date_CMHG 21 Jan 2018 -#define Module_MajorVersion "0.98" -#define Module_Version 98 +#define Module_MajorVersion "0.99" +#define Module_Version 99 #define Module_MinorVersion "" -#define Module_Date "22 Nov 2014" +#define Module_Date "21 Jan 2018" -#define Module_ApplicationDate "22-Nov-14" +#define Module_ApplicationDate "21-Jan-18" #define Module_ComponentName "IntKey" #define Module_ComponentPath "castle/RiscOS/Sources/Internat/IntKey" -#define Module_FullVersion "0.98" -#define Module_HelpVersion "0.98 (22 Nov 2014)" -#define Module_LibraryVersionInfo "0:98" +#define Module_FullVersion "0.99" +#define Module_HelpVersion "0.99 (21 Jan 2018)" +#define Module_LibraryVersionInfo "0:99" diff --git a/c/keyconvert b/c/keyconvert index bfd66a1..a041d97 100644 --- a/c/keyconvert +++ b/c/keyconvert @@ -258,6 +258,7 @@ int main(int argc, char **argv) out = fopen(argv[2], "w"); if (!out) { + fclose(in); perror(argv[2]); exit(1); } @@ -268,6 +269,7 @@ int main(int argc, char **argv) flags = read_int(in); #ifdef UNIX error("Unable to translate alphabet numbers under UNIX"); + alphabet_no = -1; #else _swix(OS_ServiceCall, _INR(1,3)|_OUT(1)|_OUT(4), 0x43, 1, alphabet, @@ -333,7 +335,7 @@ int main(int argc, char **argv) fprintf(out, "SPECIAL KEY CONFIGURED KEYBOARD\n"); continue; } - if (i==0x0C && j ==6) + if (i==0x0C && j == 6) { fprintf(out, "SPECIAL KEY DIAL KEYBOARD\n"); continue; @@ -437,7 +439,11 @@ int main(int argc, char **argv) fprintf(out, "$EndKeypad\n"); } - return 0; - + /* Tidy up */ + fclose(in); + fclose(out); + free(cno); + free(alphabet); + return 0; } diff --git a/c/keygen b/c/keygen index fdab56c..65cf4fe 100644 --- a/c/keygen +++ b/c/keygen @@ -1062,6 +1062,7 @@ static void process_keyboard(FILE *in, FILE *out) fprintf(out, "\n ALIGN\n"); fprintf(out, "\n END\n"); + free(kb); } int main(int argc, char **argv) diff --git a/c/unicdata b/c/unicdata index f4e1b4b..07b266f 100644 --- a/c/unicdata +++ b/c/unicdata @@ -233,7 +233,7 @@ UCS4 UCS_from_name(const char *name) if (strncmp(name, "CJK UNIFIED IDEOGRAPH-", 22)==0) { UCS4 c=extract_code(name+22); - if (!((c>=0x3400 && c<=0x4DB5) || (c>=0x4E00 || c<=0x9FA5))) + if (!((c>=0x3400 && c<=0x4DB5) || (c>=0x4E00 && c<=0x9FA5))) error("Bad ideograph"); return c; } -- GitLab