libnm/tests: avoid Coverity warning in test code _do_test_utils_str_utf8safe_unescape()

Error: FORWARD_NULL (CWE-476): [#def435]
    NetworkManager-1.31.5/src/libnm-core-impl/tests/test-general.c:9084: var_compare_op: Comparing "str" to null implies that "str" might be null.
    NetworkManager-1.31.5/src/libnm-core-impl/tests/test-general.c:9105: var_deref_model: Passing null pointer "str" to "strchr", which dereferences it.
    # 9103|           s = nm_utils_str_utf8safe_unescape(str, NM_UTILS_STR_UTF8_SAFE_FLAG_NONE, &str_free_1);
    # 9104|           g_assert_cmpstr(s, ==, expected);
    # 9105|->         if (strchr(str, '\\')) {
    # 9106|               g_assert(str_free_1 != str);
    # 9107|               g_assert(s == str_free_1);
This commit is contained in:
Thomas Haller 2021-05-25 22:48:52 +02:00
parent 6646ee6546
commit a559950d41
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -9102,6 +9102,7 @@ _do_test_utils_str_utf8safe_unescape(const char *str, const char *expected, gsiz
/* there are no embedded NULs. Check that nm_utils_str_utf8safe_unescape() yields the same result. */
s = nm_utils_str_utf8safe_unescape(str, NM_UTILS_STR_UTF8_SAFE_FLAG_NONE, &str_free_1);
g_assert_cmpstr(s, ==, expected);
g_assert(str);
if (strchr(str, '\\')) {
g_assert(str_free_1 != str);
g_assert(s == str_free_1);