gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 70/208: test1537: fixed memory leak on OOM


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 70/208: test1537: fixed memory leak on OOM
Date: Wed, 09 Aug 2017 17:34:27 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to annotated tag gnurl-7.55.0
in repository gnurl.

commit bec809cb2ee0136a911c1229d9a6f03c4904ed86
Author: Dan Fandrich <address@hidden>
AuthorDate: Sun Jun 25 22:59:55 2017 +0200

    test1537: fixed memory leak on OOM
---
 tests/libtest/lib1537.c | 15 +++++++++++++--
 1 file 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;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]