Add checking of dbus_message_iter_append_basic return value

Coverity complains that the test suite did not check the
return value of dbus_message_iter_append_basic() as we did
in most other places.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-09-20 11:47:33 +01:00
parent 30bb4c4b54
commit 83c24493df

View File

@ -82,10 +82,8 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connectio
dbus_message_iter_init_append(reply, &iter); dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_append_basic(&iter, if (!dbus_message_iter_append_basic(&iter,
DBUS_TYPE_STRING, DBUS_TYPE_STRING,
&error_message)) { &error_message))
dbus_message_unref(reply); goto error;
return NULL;
}
} else { } else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
} }
@ -98,19 +96,25 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connectio
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"s", &sub); "s", &sub);
dbus_message_iter_append_basic(&sub, if (!dbus_message_iter_append_basic(&sub,
DBUS_TYPE_STRING, DBUS_TYPE_STRING,
&svc1); &svc1))
if (!getenv("FAIL_NO_SERVICE")) goto error;
dbus_message_iter_append_basic(&sub, if (!getenv("FAIL_NO_SERVICE") &&
DBUS_TYPE_STRING, !dbus_message_iter_append_basic(&sub,
&svc2); DBUS_TYPE_STRING,
&svc2))
goto error;
dbus_message_iter_close_container(&iter, &sub); dbus_message_iter_close_container(&iter, &sub);
} else { } else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
} }
return reply; return reply;
error:
dbus_message_unref(reply);
return NULL;
} }
#else #else