aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-12 13:04:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-12 13:04:30 +0000
commitc123676825719c3188becfc238ec83251e923867 (patch)
tree93ad2b75aa64012644a426734ac2cfdb00eb313a
parentd60c22572b49cde9b839a59510580df079d2d5e2 (diff)
return NULL on out of memory
-rw-r--r--lib/escape.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/escape.c b/lib/escape.c
index b233600af..87d3a79e2 100644
--- a/lib/escape.c
+++ b/lib/escape.c
@@ -39,12 +39,16 @@
char *curl_escape(const char *string, int length)
{
size_t alloc = (length?(size_t)length:strlen(string))+1;
- char *ns = malloc(alloc);
+ char *ns;
char *testing_ptr = NULL;
unsigned char in;
size_t newlen = alloc;
int strindex=0;
+ ns = malloc(alloc);
+ if(!ns)
+ return NULL;
+
length = alloc-1;
while(length--) {
in = *string;
@@ -90,9 +94,8 @@ char *curl_unescape(const char *string, int length)
int strindex=0;
long hex;
- if( !ns ) {
+ if( !ns )
return NULL;
- }
while(--alloc > 0) {
in = *string;