• E
    util: Fix virGetLastErrorMessage to return proper error when 'err' is NULL · e711a391
    Erik Skultety 提交于
    Both virGetLastError and virGetLastErrorMessage call virLastErrorObject method
    that returns a thread-local error object. However, if a direct call to malloc
    or pthread_setspecific (probably also due to malloc, since it sets ENOMEM)
    fail, virLastErrorObject returns NULL which, although incorrectly interpreted
    by virGetLastError as no error, still requires the caller to check for NULL
    pointer. This isn't the case with virGetLastErrorMessage that also treated it
    incorrectly as no error, but returned the literal "no error".
    This patch tweaks the checks in the virGetLastErrorMessage function, so that
    if virLastErrorObject failed, it returned "unknown error" which is equivalent
    to the current approach with virGetLastError and if it returned NULL,
    "unknown error" was set.
    Signed-off-by: NErik Skultety <eskultet@redhat.com>
    e711a391
virerror.c 46.7 KB