Commit a3c03643 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix off by one bugs

parent 8255efa5
...@@ -1278,17 +1278,17 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, ...@@ -1278,17 +1278,17 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
* UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any * UTF-8 but also Windows-1252(!) and ISO-8859-15(!) or any
* non-western encoding, it obviously fails. * non-western encoding, it obviously fails.
*/ */
unsigned len = 1;
const wxChar *stupid = filenames[i]; const wxChar *stupid = filenames[i];
for (const wxChar *braindead = stupid; *braindead; braindead++) for (const wxChar *braindead = stupid; *braindead; braindead++);
len++;
char *psz_local = (char *)malloc (len); size_t i = (braindead - stupid);
char *psz_local = (char *)malloc( i + 1 );
do do
psz_local[len] = (char)stupid[len]; psz_local[i] = (char)stupid[i];
while (len--); while (i--);
char *psz_utf8 = FromLocale( psz_local ); const char *psz_utf8 = FromLocale( psz_local );
#else #else
char *psz_utf8 = wxFromLocale( filenames[i] ); char *psz_utf8 = wxFromLocale( filenames[i] );
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment