diff options
author | David Sommerseth <davids@redhat.com> | 2009-05-13 18:30:58 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2009-05-13 18:30:58 +0200 |
commit | c07eb6b33813e41d98d4210dbca18e5de8c8fad6 (patch) | |
tree | 8d16105aa108fdd94a3d96423b256673d67347c6 /src | |
parent | ce4d3eac5a50d25e2821a8aedf09f266b16988fe (diff) | |
download | python-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.tar.gz python-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.tar.xz python-dmidecode-c07eb6b33813e41d98d4210dbca18e5de8c8fad6.zip |
Avoid segfault if XPATH_NODESET do not contain any data
Diffstat (limited to 'src')
-rw-r--r-- | src/dmixml.c | 7 |
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; |