Discussion:
free() of idna_to_ascii_8z() buffer
Gisle Vanem
2014-02-07 16:51:33 UTC
Permalink
Hello Thomas etc.

The buffer allocated by idna_to_ascii_8z() should be freed by libidn.
That's why Simon Josefsson added the idn_free(). The '(free)' caused a
crash here since my libidn (MSVC) was built without debug, but Lynx (also MSVC)
used the debug-model (-MDd). Hence:

--- orig/WWW/Library/Implementation/HTParse.c 2013-11-29 01:52:56 +0000
+++ WWW/Library/Implementation/HTParse.c 2014-02-07 17:33:03 +0000
@@ -301,7 +301,7 @@
idna_strerror((Idna_rc) code)));
}
if (output) /* "(free)" to bypass LYLeaks.c */
- (free) (output);
+ idn_free (output);
}
free(buffer);
}

------

Btw. the stuff with USE_ALT_BINDING I reported last year,
is still an issue. W/o USE_ALT_BINDINGS, I get:

src/LYEditmap.c(1754) : error C2065: 'LYModifierBindings' : undeclared identifier
src/LYEditmap.c(1754) : error C2065: 'LYModifierBindings' : undeclared identifier
src/LYEditmap.c(1754) : error C2109: subscript requires array or pointer type
src/LYEditmap.c(1755) : error C2065: 'LYModifierBindings' : undeclared identifier
src/LYEditmap.c(1755) : error C2109: subscript requires array or pointer type
src/LYEditmap.c(1755) : error C2198: 'initLineEditor' : too few arguments for call

So:

--- orig/src/LYEditmap.c 2013-11-29 01:52:56 +0000
+++ src/LYEditmap.c 2014-02-07 17:24:52 +0000
@@ -1750,9 +1750,11 @@
LYEditorNames[j] = LYLineEditors[j].name;
initLineEditor(&LYLineEditors[j]);
}
+#ifdef USE_ALT_BINDINGS
for (j = 0; j < TABLESIZE(LYModifierBindings); ++j) {
initLineEditor(&LYModifierBindings[j]);
}
+#endif
}

--------

--gv
Thomas Dickey
2014-02-08 01:15:56 UTC
Permalink
Post by Gisle Vanem
Hello Thomas etc.
The buffer allocated by idna_to_ascii_8z() should be freed by libidn.
That's why Simon Josefsson added the idn_free(). The '(free)' caused a
crash here since my libidn (MSVC) was built without debug, but Lynx (also MSVC)
thanks - I've applied these fixes to my current code.
--
Thomas E. Dickey <***@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
Gisle Vanem
2014-02-09 11:39:49 UTC
Permalink
Post by Thomas Dickey
thanks - I've applied these fixes to my current code.
You should add this header too:

--- orig/WWW/Library/Implementation/HTParse.c 2013-11-29 01:52:56 +0000
+++ WWW/Library/Implementation/HTParse.c 2014-02-08 22:08:00 +0000
@@ -24,6 +24,7 @@

#ifdef USE_IDNA
#include <idna.h>
+#include <idn-free.h>
#endif

#define HEX_ESCAPE '%'
@@ -301,7 +302,7 @@
idna_strerror((Idna_rc) code)));
}
if (output) /* "(free)" to bypass LYLeaks.c */
- (free) (output);
+ idn_free (output);
}
free(buffer);
}

---------

I think it's not needed to version-check for the <idn-free.h> header. It was
added in libidn's infancy; probably 4 years ago.

--gv
Thomas Dickey
2014-02-09 14:05:18 UTC
Permalink
Post by Thomas Dickey
thanks - I've applied these fixes to my current code.
I did that.

Actually, I added a configure check for the header after reading the
comments in the header which tended to demonstrate that SJ wasn't
inclined to view it as part of the api. However, I see from this:

http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=history;f=lib/idn-free.h;h=982713f13c61b1ea0f5f348b30434bb230857cfb;hb=HEAD

that it's been there a while.
--
Thomas E. Dickey <***@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
Loading...