[libxml2] Fix various Missing Null checks



commit 1811add768cabe36f763c960a40698418c5cbe47
Author: Gaurav Gupta <g gupta samsung com>
Date:   Mon Jul 14 17:50:27 2014 +0800

    Fix various Missing Null checks
    
    For https://bugzilla.gnome.org/show_bug.cgi?id=732823

 hash.c     |    3 +++
 nanoftp.c  |   10 ++++++++--
 nanohttp.c |   12 ++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/hash.c b/hash.c
index 0145109..f9a2017 100644
--- a/hash.c
+++ b/hash.c
@@ -984,6 +984,9 @@ xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
        return(NULL);
 
     ret = xmlHashCreate(table->size);
+    if (ret == NULL)
+        return(NULL);
+
     if (table->table) {
        for(i = 0; i < table->size; i++) {
            if (table->table[i].valid == 0)
diff --git a/nanoftp.c b/nanoftp.c
index ab1f685..f467e5a 100644
--- a/nanoftp.c
+++ b/nanoftp.c
@@ -1244,7 +1244,13 @@ xmlNanoFTPConnectTo(const char *server, int port) {
     if (port <= 0)
        return(NULL);
     ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(NULL);
+    if (ctxt == NULL)
+        return(NULL);
     ctxt->hostname = xmlMemStrdup(server);
+    if (ctxt->hostname == NULL) {
+       xmlNanoFTPFreeCtxt(ctxt);
+       return(NULL);
+    }
     if (port != 0)
        ctxt->port = port;
     res = xmlNanoFTPConnect(ctxt);
@@ -1321,8 +1327,8 @@ xmlNanoFTPDele(void *ctx, const char *file) {
     int len;
     int res;
 
-    if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) || (file == NULL)) return(-1);
-    if (file == NULL) return (0);
+    if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) ||
+        (file == NULL)) return(-1);
 
     /*
      * Expected response code for DELE:
diff --git a/nanohttp.c b/nanohttp.c
index e9859a6..e109ad7 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -1363,17 +1363,17 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
     xmlNanoHTTPInit();
 
 retry:
-    if (redirURL == NULL)
+    if (redirURL == NULL) {
        ctxt = xmlNanoHTTPNewCtxt(URL);
-    else {
+       if (ctxt == NULL)
+           return(NULL);
+    } else {
        ctxt = xmlNanoHTTPNewCtxt(redirURL);
+       if (ctxt == NULL)
+           return(NULL);
        ctxt->location = xmlMemStrdup(redirURL);
     }
 
-    if ( ctxt == NULL ) {
-       return ( NULL );
-    }
-
     if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
        __xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI");
         xmlNanoHTTPFreeCtxt(ctxt);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]