Hello,
I think that I have found a memory leak in Libidn.

Code: main.cpp
Test: test.txt

When I run valgrind it reports a memory leak:

valgrind --tool=memcheck --leak-check=full  ./main < test.txt
==19727== Memcheck, a memory error detector
==19727== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==19727== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for
copyright info
==19727== Command: ./main
==19727==
==19727==
==19727== HEAP SUMMARY:
==19727==     in use at exit: 26 bytes in 3 blocks
==19727==   total heap usage: 56 allocs, 53 frees, 9,553 bytes allocated
==19727==
==19727== For counts of detected and suppressed errors, rerun with: -v
==19727== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)

My patch for idna.c (
http://www.gnu.org/software/libidn/doxygen/idna_8c_source.html):


00508         {
00509           rc = idna_to_ascii_4i (start, (size_t) (end - start), buf,
flags);
00510           if (rc != IDNA_SUCCESS)
-                 return rc;
+                 {
+                   free (out);
+                   return rc;
+                 }
00512           }

Regards,
Olga.
search...
google.com................point
Loading...°°°°°°°°°°°°°°]
#include <iostream>
#include <string>

#include <contrib/libs/libidn/idna.h>

using namespace std;

int main() {
    string url;

    while (cin >> url) {
        char* udata = 0;
        if (idna_to_ascii_8z(url.c_str(), &udata, 0) == IDNA_SUCCESS) {
            free(udata);
        }
    }
    return 0;
}
_______________________________________________
Help-libidn mailing list
Help-libidn@gnu.org
https://lists.gnu.org/mailman/listinfo/help-libidn

Reply via email to