[R-SIG-Mac] download.file crashes R when 404 is returned

Seth Falcon sfalcon at fhcrc.org
Thu Jul 27 19:10:46 CEST 2006


Seth Falcon <sfalcon at fhcrc.org> writes:
> I noticed these comments in internet.c:
>
> 	if(rc != 200) {
> 	    char *msg;
> 	    RxmlNanoHTTPClose(ctxt);
> 	    /* bug work-around: it will crash on OS X if passed directly */
> 	    msg = _("cannot open: HTTP status was '%d %s'");
> 	    warning(msg, rc, RxmlNanoHTTPStatusMsg(ctxt));
> 	    return NULL;

So it looked kind of weird to me that RxmlNanoHTTPClose gets called
_before_ the RxmlNanoHTTPStatusMsg call.  I tried moving the close
call to after the call to warning and the crash went away (patch
below).

Can anyone confirm/deny/refute?

+ seth


diff --git a/src/modules/internet/internet.c b/src/modules/internet/internet.c
index 80e507a..f9175b1 100644
--- a/src/modules/internet/internet.c
+++ b/src/modules/internet/internet.c
@@ -489,10 +489,10 @@ void *in_R_HTTPOpen(const char *url, int
        int rc = RxmlNanoHTTPReturnCode(ctxt);
        if(rc != 200) {
            char *msg;
-           RxmlNanoHTTPClose(ctxt);
            /* bug work-around: it will crash on OS X if passed directly */
            msg = _("cannot open: HTTP status was '%d %s'");
            warning(msg, rc, RxmlNanoHTTPStatusMsg(ctxt));
+           RxmlNanoHTTPClose(ctxt);
            return NULL;
        } else {
            type = RxmlNanoHTTPContentType(ctxt);



More information about the R-SIG-Mac mailing list