Hey alltogether,

With this .netrc:

 machine localhost
 default login anonymous password joe@

I get this:

 $ wget ftp.kernel.org/pub/linux/kernel/v2.0/patch-2.0.1.gz
 --13:03:13--  http://ftp.kernel.org/pub/linux/kernel/v2.0/patch-2.0.1.gz
            => `patch-2.0.1.gz'
 wget: xmalloc.c:186: xfree_real: Assertion `ptr != ((void *)0)' failed.

I've gotten this backtrace:

 (gdb) bt
 #0  0xffffe410 in ?? ()
 #1  0xbfffe94c in ?? ()
 #2  0x00000006 in ?? ()
 #3  0x00001cb4 in ?? ()
 #4  0x40186d41 in raise () from /lib/tls/libc.so.6
 #5  0x40188529 in abort () from /lib/tls/libc.so.6
 #6  0x40180573 in __assert_fail () from /lib/tls/libc.so.6
 #7  0x0806fa33 in xfree_real (ptr=0x0) at xmalloc.c:186
 #8  0x080645fa in maybe_add_to_list (newentry=0xbfffeb2c, list=0xbfffeb28)
     at netrc.c:219
 #9  0x080649ce in parse_netrc (path=0xbfffeb60 "/suse/mmj/.netrc") at 
netrc.c:401
 #10 0x0806448b in search_netrc (host=0x8085f08 "kernel.org", acc=0xbfffed0c,
     passwd=0xbfffed08, slack_default=1) at netrc.c:94
 #11 0x0804f8f2 in getftp (u=0x8086508, len=0xbfffeef8, restval=0, 
con=0xbfffefb0)
     at ftp.c:264
 #12 0x08051f58 in ftp_loop_internal (u=0x8086508, f=0x0, con=0xbfffefb0)
     at ftp.c:1229
 #13 0x080533d0 in ftp_loop (u=0x8086508, dt=0xbffff138, proxy=0x0) at 
ftp.c:1891
 #14 0x08068e59 in retrieve_url (
     origurl=0x8086488 "ftp://kernel.org/pub/linux/kernel/v2.0/patch-2.0.1.gz";,
     file=0xbffff130, newloc=0xbffff134, refurl=0x0, dt=0xbffff138) at 
retr.c:658
 #15 0x0806403d in main (argc=2, argv=0xbffff1f4) at main.c:915

So since these pointers apparantly _can_ be NULL, how about the
following patch:

--- src/netrc.c
+++ src/netrc.c
@@ -215,9 +215,9 @@
   if (a && ! a->acc)
     {
       /* Free any allocated space.  */
-      xfree (a->host);
-      xfree (a->acc);
-      xfree (a->passwd);
+      xfree_null (a->host);
+      xfree_null (a->acc);
+      xfree_null (a->passwd);
     }
   else
     {

-- 
Mads Martin Joergensen, http://mmj.dk                           BÅK!
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.

Reply via email to