mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Make save_string null-safe
It simply returns nullptr when the saved string is null.
This commit is contained in:
parent
628e3d2aed
commit
f2609b1a9b
1 changed files with 8 additions and 4 deletions
|
@ -139,12 +139,16 @@ ss_get_key (const void *s, void *unused)
|
||||||
const char *
|
const char *
|
||||||
save_string (const char *str)
|
save_string (const char *str)
|
||||||
{
|
{
|
||||||
char *s;
|
if (!str) {
|
||||||
if (!saved_strings)
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (!saved_strings) {
|
||||||
saved_strings = Hash_NewTable (16381, ss_get_key, 0, 0, 0);
|
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;
|
return s;
|
||||||
|
}
|
||||||
s = strdup (str);
|
s = strdup (str);
|
||||||
Hash_Add (saved_strings, s);
|
Hash_Add (saved_strings, s);
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue