diff options
author | Matthew Daley <mattjd@gmail.com> | 2013-09-27 23:29:10 +1200 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2013-10-03 13:37:17 +0100 |
commit | a7fa7a4fd6b94c2ace19774ba4ba9f0185c2f2c1 (patch) | |
tree | b51a5d3e1844ad20c19dae4b5906e7e3ee808462 /tools/libxl/libxl.c | |
parent | ca145fe70bad3a25ad54c6ded1ef237e45a2311e (diff) | |
download | xen-a7fa7a4fd6b94c2ace19774ba4ba9f0185c2f2c1.tar.gz xen-a7fa7a4fd6b94c2ace19774ba4ba9f0185c2f2c1.tar.bz2 xen-a7fa7a4fd6b94c2ace19774ba4ba9f0185c2f2c1.zip |
libxl: handle null lists in libxl_string_list_length
After commit b0be2b12 ("libxl: fix libxl_string_list_length and its only
caller") libxl_string_list_length no longer handles null (empty) lists. Fix
so they are handled, returning length 0.
While at it, remove the unneccessary undereferenced null pointer check
and tidy the layout of the function.
Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl.c')
-rw-r--r-- | tools/libxl/libxl.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index ca24ca37cd..b6daceaf9b 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -200,9 +200,12 @@ void libxl_string_list_dispose(libxl_string_list *psl) int libxl_string_list_length(const libxl_string_list *psl) { - if (!psl) return 0; int i = 0; - while ((*psl)[i]) i++; + + if (*psl) + while ((*psl)[i]) + i++; + return i; } |