diff options
-rw-r--r-- | src/core/wee-string.c | 3 | ||||
-rw-r--r-- | tests/unit/core/test-core-string.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 10e2bcaca..6741f9e66 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -3616,6 +3616,9 @@ string_shared_get (const char *string) char *key; int length; + if (!string) + return NULL; + if (!string_hashtable_shared) { /* diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 1c792efc9..1f8938091 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -1839,7 +1839,10 @@ TEST(CoreString, Shared) const char *str1, *str2, *str3; int count; - count = string_hashtable_shared->items_count; + count = (string_hashtable_shared) ? + string_hashtable_shared->items_count : 0; + + POINTERS_EQUAL(NULL, string_shared_get (NULL)); str1 = string_shared_get ("this is a test"); CHECK(str1); |