aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-17 22:07:43 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-17 22:07:43 +0000
commite9056f5f957323dc09d44a2c038125334ce4f652 (patch)
treed00327be6235d3da68512f0bebb361e5e3259411
parenta9893ca79aa8ee090da91089e89c7f43f6b83443 (diff)
if shrinking the buffer fails, use the older larger one
-rw-r--r--lib/hostip.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index c4e5ebfee..ffc8198ea 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -623,8 +623,14 @@ Curl_addrinfo *Curl_addrinfo_copy(Curl_addrinfo *orig)
most often is only a fraction of the original alloc */
newbuf=(char *)realloc(aptr, (long)(bufptr-aptr));
+ if(!newbuf) {
+ /* serious error, but since this is shrinking only requested, we can
+ still use the previous memory block */
+ newbuf = aptr;
+ }
+
/* if the alloc moved, we need to adjust the hostent struct */
- if(newbuf != aptr)
+ else if(newbuf != aptr)
Curl_hostent_relocate((struct hostent*)newbuf, (long)(newbuf-aptr));
/* setup the return */