]> granicus.if.org Git - curl/commitdiff
fix an OOM problem detected by Jim Meyering
authorDaniel Stenberg <daniel@haxx.se>
Fri, 14 Nov 2008 16:26:39 +0000 (16:26 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 14 Nov 2008 16:26:39 +0000 (16:26 +0000)
lib/formdata.c

index e035271b34951c00a460ce3c83316b82ec350cd8..a370e65a4b057ee4e6344836cb8959ec559cefef 100644 (file)
@@ -1100,7 +1100,7 @@ static char *strippath(const char *fullfile)
 
   free(filename); /* free temporary buffer */
 
-  return base; /* returns an allocated string! */
+  return base; /* returns an allocated string or NULL ! */
 }
 
 /*
@@ -1207,8 +1207,12 @@ CURLcode Curl_getFormData(struct FormData **finalform,
 
       if(post->more) {
         /* if multiple-file */
-        char *filebasename=
-          (!file->showfilename)?strippath(file->contents):NULL;
+        char *filebasename= NULL;
+        if(!file->showfilename) {
+          filebasename = strippath(file->contents);
+          if(!filebasename)
+            return CURLE_OUT_OF_MEMORY;
+        }
 
         result = AddFormDataf(&form, &size,
                               "\r\n--%s\r\nContent-Disposition: "