From f2609b1a9bc6e66a99492ca48208a8fb70398013 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 7 Jul 2024 15:18:51 +0900 Subject: [PATCH] [qfcc] Make save_string null-safe It simply returns nullptr when the saved string is null. --- tools/qfcc/source/strpool.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/qfcc/source/strpool.c b/tools/qfcc/source/strpool.c index 998d09e99..6d4a04f26 100644 --- a/tools/qfcc/source/strpool.c +++ b/tools/qfcc/source/strpool.c @@ -139,12 +139,16 @@ ss_get_key (const void *s, void *unused) const char * save_string (const char *str) { - char *s; - if (!saved_strings) + if (!str) { + return nullptr; + } + if (!saved_strings) { saved_strings = Hash_NewTable (16381, ss_get_key, 0, 0, 0); - s = Hash_Find (saved_strings, str); - if (s) + } + char *s = Hash_Find (saved_strings, str); + if (s) { return s; + } s = strdup (str); Hash_Add (saved_strings, s); return s;