[PATCH 04/25] util: validate return from xmlNodeGetContent before use

Laine Stump laine at redhat.com
Fri Jun 26 23:14:19 UTC 2020

On 6/25/20 6:55 PM, Ján Tomko wrote:
> On a Wednesday in 2020, Laine Stump wrote:
>> There were a few uses of xmlNodeGetContent() that didn't check for
>> NULL before using the result.
>> A NULL return from xmlNodeGetContent() *could* (probably does) mean
>> that there was an Out of Memory condition, but it is unclear from the
>> documentation if that is always the case, or if it could just indicate
>> a missing value in the document, so we don't report an OOM error, but
>> just don't try to use it for, e.g., conversion to an integer.
> Is it possible to have an element with "no value"?

I never found anywhere that said "No". But I also never found anywhere 
that says "yes", so I opted for "do no harm" (or something like that).

> Even <wwn/> gives me an empty string instead of NULL.

Okay, *that* says "No". So I'll change the patch to always report an OOM 

> Jano
>> Signed-off-by: Laine Stump <laine at redhat.com>
>> ---
>> src/conf/domain_conf.c | 28 ++++++++++++++--------------
>> 1 file changed, 14 insertions(+), 14 deletions(-)

More information about the libvir-list mailing list