summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-05-13 18:30:58 +0200
committerDavid Sommerseth <davids@redhat.com>2009-05-13 18:30:58 +0200
commitc07eb6b33813e41d98d4210dbca18e5de8c8fad6 (patch)
tree8d16105aa108fdd94a3d96423b256673d67347c6
parentce4d3eac5a50d25e2821a8aedf09f266b16988fe (diff)
downloadpython-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.tar.gz
python-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.tar.xz
python-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.zip
Avoid segfault if XPATH_NODESET do not contain any data
-rw-r--r--src/dmixml.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dmixml.c b/src/dmixml.c
index 65f5e07..dbca0c3 100644
--- a/src/dmixml.c
+++ b/src/dmixml.c
@@ -228,7 +228,12 @@ char *dmixml_GetXPathContent(char *buf, size_t buflen, xmlXPathObject *xpo, int
case XPATH_NODESET:
if( (xpo->nodesetval != NULL) && (xpo->nodesetval->nodeNr >= (idx+1)) ) {
- strncpy(buf, dmixml_GetContent(xpo->nodesetval->nodeTab[idx]), buflen-1);
+ char *str = dmixml_GetContent(xpo->nodesetval->nodeTab[idx]);
+ if( str != NULL ) {
+ strncpy(buf, str, buflen-1);
+ } else {
+ memset(buf, 0, buflen);
+ }
}
break;