]> granicus.if.org Git - curl/commitdiff
openldap: OOM fixes
authorDaniel Stenberg <daniel@haxx.se>
Fri, 8 Jun 2012 18:56:22 +0000 (20:56 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 8 Jun 2012 18:57:11 +0000 (20:57 +0200)
when calloc fails, return error! (Detected by Fortify)

Reported by: Robert B. Harris

lib/openldap.c

index 3886d0889efc0c4c683377b94b6a3d3165fa7a36..9ccfa7faeb8dc935b106ecbd89f5e28674abff08 100644 (file)
@@ -171,6 +171,8 @@ static CURLcode ldap_setup(struct connectdata *conn)
   ldap_free_urldesc(lud);
 
   li = calloc(1, sizeof(ldapconninfo));
+  if(!li)
+    return CURLE_OUT_OF_MEMORY;
   li->proto = proto;
   conn->proto.generic = li;
   conn->bits.close = FALSE;
@@ -386,6 +388,8 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
     return CURLE_LDAP_SEARCH_FAILED;
   }
   lr = calloc(1,sizeof(ldapreqinfo));
+  if(!lr)
+    return CURLE_OUT_OF_MEMORY;
   lr->msgid = msgid;
   data->state.proto.generic = lr;
   Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);