cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: memlimit fail

From: Gisle Vanem <giva_at_bgnett.no>
Date: Mon, 07 Feb 2005 20:57:40 +0100

> Ah, right, since it'll stop there and not continue. What about the attached
> patch? I think it needs some attention for the windows threaded resolver.

Presto!

I still want the resolver callbacks to return a CURLcode. So the message
becomes:

> CWD dir
< 250 CWD command successful.
LIMIT llist.c:66 malloc reached memlimit
* Could not resolve host: out of memory

(the failure is before the PORT command). Take a look at the attached
patch before I commit anything.

There's also a potential bug in freedirs() if realloc() fails:

diff -u -r1.296 ftp.c
--- ftp.c 4 Feb 2005 23:43:44 -0000 1.296
+++ ftp.c 7 Feb 2005 19:51:42 -0000
@@ -2754,10 +2754,9 @@

   ftp->dirdepth = 0;
   ftp->diralloc = 5; /* default dir depth to allocate */
- ftp->dirs = (char **)malloc(ftp->diralloc * sizeof(ftp->dirs[0]));
+ ftp->dirs = (char **)calloc(ftp->diralloc, sizeof(ftp->dirs[0]));
   if(!ftp->dirs)
     return CURLE_OUT_OF_MEMORY;
- ftp->dirs[0] = NULL; /* to start with */

   /* parse the URL path into separate path components */
   while((slash_pos=strchr(cur_pos, '/'))) {
@@ -2795,6 +2794,7 @@
         ftp->diralloc *= 2; /* double the size each time */
         bigger = realloc(ftp->dirs, ftp->diralloc * sizeof(ftp->dirs[0]));
         if(!bigger) {
+ ftp->dirdepth--;
           freedirs(ftp);
           return CURLE_OUT_OF_MEMORY;
         }

--gv

Received on 2005-02-07