mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
return NULL on out of memory
This commit is contained in:
parent
d60c22572b
commit
c123676825
@ -39,12 +39,16 @@
|
|||||||
char *curl_escape(const char *string, int length)
|
char *curl_escape(const char *string, int length)
|
||||||
{
|
{
|
||||||
size_t alloc = (length?(size_t)length:strlen(string))+1;
|
size_t alloc = (length?(size_t)length:strlen(string))+1;
|
||||||
char *ns = malloc(alloc);
|
char *ns;
|
||||||
char *testing_ptr = NULL;
|
char *testing_ptr = NULL;
|
||||||
unsigned char in;
|
unsigned char in;
|
||||||
size_t newlen = alloc;
|
size_t newlen = alloc;
|
||||||
int strindex=0;
|
int strindex=0;
|
||||||
|
|
||||||
|
ns = malloc(alloc);
|
||||||
|
if(!ns)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
length = alloc-1;
|
length = alloc-1;
|
||||||
while(length--) {
|
while(length--) {
|
||||||
in = *string;
|
in = *string;
|
||||||
@ -90,9 +94,8 @@ char *curl_unescape(const char *string, int length)
|
|||||||
int strindex=0;
|
int strindex=0;
|
||||||
long hex;
|
long hex;
|
||||||
|
|
||||||
if( !ns ) {
|
if( !ns )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
while(--alloc > 0) {
|
while(--alloc > 0) {
|
||||||
in = *string;
|
in = *string;
|
||||||
|
Loading…
Reference in New Issue
Block a user