mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
tests: Fix logic to not have possible NULL deref
It's possible that virBitmapNewString returns NULL with an error string (and not an allocation failure that would abort); however, if virBitmapToString is called with a NULL @bitmap, then it will fail in an ugly manner. So rather than have if (!map && !str) logic, split the checks for each variable. Found by Coverity Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
77180d0f70
commit
3f3f74dbc7
@ -682,9 +682,11 @@ test13(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
|
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
|
||||||
map = virBitmapNewString(strings[i]);
|
map = virBitmapNewString(strings[i]);
|
||||||
str = virBitmapToString(map, false, true);
|
if (!map)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!map || !str)
|
str = virBitmapToString(map, false, true);
|
||||||
|
if (!str)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (STRNEQ(strings[i], str)) {
|
if (STRNEQ(strings[i], str)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user