Skip to content

Commit

Permalink
Fix various Missing Null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ya1gaurav authored and veillard committed Jul 14, 2014
1 parent c836ba6 commit 1811add
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions nanoftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions nanohttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1811add

Please sign in to comment.