diff options
| author | Dan Fandrich <dan@coneharvesters.com> | 2017-06-25 22:59:55 +0200 | 
|---|---|---|
| committer | Dan Fandrich <dan@coneharvesters.com> | 2017-06-25 22:59:55 +0200 | 
| commit | bec809cb2ee0136a911c1229d9a6f03c4904ed86 (patch) | |
| tree | c88c11da26f7430085f88077f80c6ac0d8da9a60 /tests/libtest | |
| parent | e8a4da67f5d041f6fac0a1fea20d58bf5f151691 (diff) | |
test1537: fixed memory leak on OOM
Diffstat (limited to 'tests/libtest')
| -rw-r--r-- | tests/libtest/lib1537.c | 15 | 
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/libtest/lib1537.c b/tests/libtest/lib1537.c index d449164e4..b07d64fc5 100644 --- a/tests/libtest/lib1537.c +++ b/tests/libtest/lib1537.c @@ -25,8 +25,8 @@  int test(char *URL)  { -  unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, -                       0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7}; +  const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, +                             0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};    CURLcode res = CURLE_OK;    char *ptr = NULL;    int asize; @@ -49,6 +49,10 @@ int test(char *URL)    /* deprecated API */    ptr = curl_escape((char *)a, asize);    printf("%s\n", ptr); +  if(!ptr) { +    res = TEST_ERR_MAJOR_BAD; +    goto test_cleanup; +  }    raw = curl_easy_unescape(NULL, ptr, (int)strlen(ptr), &outlen);    printf("outlen == %d\n", outlen); @@ -59,6 +63,10 @@ int test(char *URL)    /* deprecated API */    raw = curl_unescape(ptr, (int)strlen(ptr)); +  if(!raw) { +    res = TEST_ERR_MAJOR_BAD; +    goto test_cleanup; +  }    outlen = (int)strlen(raw);    printf("[old] outlen == %d\n", outlen);    printf("[old] unescape == original? %s\n", @@ -77,6 +85,9 @@ int test(char *URL)    ptr = curl_easy_unescape(NULL, (char *)"moahahaha", -1, &outlen);    printf("unescape -1 length: %s %d\n", ptr, outlen); +test_cleanup: +  if(ptr) +    curl_free(ptr);    curl_global_cleanup();    return (int)res;  | 
