From 83adb758f73ebc6a6c09b7dee82e139317b7ad0a Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 30 Nov 2011 18:50:24 +0000 Subject: Make http implementation more robust --- TODO | 2 -- util.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/TODO b/TODO index cb862d5..b4bc96c 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,6 @@ use the correct file extension depending on the image type (for google and amazo bug in get() & post(): if the \r\n\r\n after http headers is cut off between recv buffers -what happens if we receive not a http header? does recv loop forever, in a memory killing manner? - package for osx - https://github.com/kennethreitz/osx-gcc-installer add djvu convert script diff --git a/util.c b/util.c index 207024a..b1f4c69 100644 --- a/util.c +++ b/util.c @@ -92,7 +92,7 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf) } *buf = realloc(*buf, sizeof(char *) * (l+BUFSIZ)); - for(; (res = recv(fd, *buf+l, BUFSIZ, 0)) > 0; l+=res) + for(; buf != NULL && (res = recv(fd, *buf+l, BUFSIZ, 0)) > 0; l+=res) *buf = realloc(*buf, sizeof(char *) * (l+BUFSIZ)); return l; -- cgit v1.2.3