klavaro: patch to fix invalid free

This commit is contained in:
Will Dietz 2022-03-13 21:43:03 -05:00
parent 65eed885d6
commit 09c7cf2f4e
2 changed files with 73 additions and 0 deletions

View file

@ -26,6 +26,8 @@ stdenv.mkDerivation rec {
substituteInPlace src/tutor.c --replace '"espeak ' '"${espeak}/bin/espeak ' substituteInPlace src/tutor.c --replace '"espeak ' '"${espeak}/bin/espeak '
''; '';
patches = [ ./trans_lang_get_similar.patch ];
postInstall = '' postInstall = ''
wrapProgram $out/bin/klavaro \ wrapProgram $out/bin/klavaro \
--prefix LD_LIBRARY_PATH : $out/lib --prefix LD_LIBRARY_PATH : $out/lib

View file

@ -0,0 +1,71 @@
--- a/src/translation.c (revision 137)
+++ b/src/translation.c (working copy)
@@ -257,23 +257,23 @@
* Private auxiliar function
*/
static gboolean
-trans_lang_get_similar (gchar * test)
+trans_lang_get_similar (gchar ** test)
{
gint i;
gchar aux_code_2[3];
/* Prefer C over en_GB for English variants other than en_GB. (Debian patch 02) */
- if (g_str_has_prefix (test, "en"))
+ if (g_str_has_prefix (*test, "en"))
{
- g_free (test);
- test = g_strdup ("C");
+ g_free (*test);
+ *test = g_strdup ("C");
return (TRUE);
}
- if (g_str_equal (test, "C"))
+ if (g_str_equal (*test, "C"))
return TRUE;
- strncpy (aux_code_2, test, 2);
+ strncpy (aux_code_2, *test, 2);
aux_code_2[2] = '\0';
for (i = 0; i < lang_num; i++)
@@ -280,15 +280,15 @@
{
if (strstr (lang[i].code, aux_code_2))
{
- g_free (test);
- test = g_strdup (lang[i].code);
+ g_free (*test);
+ *test = g_strdup (lang[i].code);
break;
}
}
- if (i == lang_num && g_str_has_prefix (test, "en"))
+ if (i == lang_num && g_str_has_prefix (*test, "en"))
{
- g_free (test);
- test = g_strdup ("C");
+ g_free (*test);
+ *test = g_strdup ("C");
return (TRUE);
}
return (i == lang_num ? FALSE : TRUE);
@@ -356,7 +356,7 @@
lang_ok = (i == 0 ? TRUE : FALSE);
break;
}
- lang_ok = trans_lang_get_similar (tmp_code);
+ lang_ok = trans_lang_get_similar (&tmp_code);
if (lang_ok == TRUE)
break;
g_free (tmp_code);
@@ -368,7 +368,7 @@
tmp_code = g_win32_getlocale ();
lang_ok = trans_lang_is_available (tmp_code);
if (lang_ok == FALSE)
- lang_ok = trans_lang_get_similar (tmp_code);
+ lang_ok = trans_lang_get_similar (&tmp_code);
#endif
}
if (tmp_code == NULL)