ifcfg-rh: avoid coverity false positive in write_secrets()

Comparing @secrets_keys indicates to coverity that it might be NULL.
Below, we access @secrets_keys without check, and coverity doesn't realize
that this cannot crash, because secrets_keys_n would be zero too.

Anyway, this way we safe the sorting, in case we only have
one element.
This commit is contained in:
Thomas Haller 2017-11-15 18:17:58 +01:00
parent 8cb86d947c
commit cfdb962ebd

View file

@ -150,7 +150,7 @@ write_secrets (shvarFile *ifcfg,
/* sort the keys. */
secrets_keys = (const char **) g_hash_table_get_keys_as_array (secrets, &secrets_keys_n);
if (secrets_keys) {
if (secrets_keys_n > 1) {
g_qsort_with_data (secrets_keys,
secrets_keys_n,
sizeof (const char *),