mem leak: both textdir() and uppercase() allocate
This commit is contained in:
parent
f04649ccf4
commit
35329205f9
1 changed files with 22 additions and 10 deletions
|
|
@ -9083,7 +9083,7 @@ static void wordwrap_text(const char * const str, SDL_Color color,
|
||||||
if (want_right_to_left == 0)
|
if (want_right_to_left == 0)
|
||||||
locale_str = strdup(gettext(str));
|
locale_str = strdup(gettext(str));
|
||||||
else
|
else
|
||||||
locale_str = strdup(textdir(gettext(str)));
|
locale_str = textdir(gettext(str));
|
||||||
|
|
||||||
|
|
||||||
/* For each UTF8 character: */
|
/* For each UTF8 character: */
|
||||||
|
|
@ -9267,10 +9267,17 @@ static void wordwrap_text(const char * const str, SDL_Color color,
|
||||||
{
|
{
|
||||||
/* Truncate if too big! (sorry!) */
|
/* Truncate if too big! (sorry!) */
|
||||||
|
|
||||||
if (want_right_to_left == 0)
|
{
|
||||||
tstr = strdup(uppercase(gettext(str)));
|
char *s1 = gettext(str);
|
||||||
else
|
if (want_right_to_left)
|
||||||
tstr = strdup(uppercase(textdir(gettext(str))));
|
{
|
||||||
|
char *freeme = s1;
|
||||||
|
s1 = textdir(s1);
|
||||||
|
free(freeme);
|
||||||
|
}
|
||||||
|
tstr = uppercase(s1);
|
||||||
|
free(s1);
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(tstr) > sizeof(substr) - 1)
|
if (strlen(tstr) > sizeof(substr) - 1)
|
||||||
tstr[sizeof(substr) - 1] = '\0';
|
tstr[sizeof(substr) - 1] = '\0';
|
||||||
|
|
@ -10245,7 +10252,7 @@ static int do_prompt(const char * const text, const char * const btn_yes, const
|
||||||
SDL_Color black = {0, 0, 0, 0};
|
SDL_Color black = {0, 0, 0, 0};
|
||||||
SDLKey key;
|
SDLKey key;
|
||||||
SDLKey key_y, key_n;
|
SDLKey key_y, key_n;
|
||||||
char keystr[200];
|
char *keystr;
|
||||||
#ifndef NO_PROMPT_SHADOWS
|
#ifndef NO_PROMPT_SHADOWS
|
||||||
int i;
|
int i;
|
||||||
SDL_Surface * alpha_surf;
|
SDL_Surface * alpha_surf;
|
||||||
|
|
@ -10254,11 +10261,13 @@ static int do_prompt(const char * const text, const char * const btn_yes, const
|
||||||
|
|
||||||
/* FIXME: Move elsewhere! Or not?! */
|
/* FIXME: Move elsewhere! Or not?! */
|
||||||
|
|
||||||
strcpy(keystr, textdir(gettext("Yes")));
|
keystr = textdir(gettext("Yes"));
|
||||||
key_y = tolower(keystr[0]);
|
key_y = tolower(keystr[0]);
|
||||||
|
free(keystr);
|
||||||
|
|
||||||
strcpy(keystr, textdir(gettext("No")));
|
keystr = textdir(gettext("No"));
|
||||||
key_n = tolower(keystr[0]);
|
key_n = tolower(keystr[0]);
|
||||||
|
free(keystr);
|
||||||
|
|
||||||
|
|
||||||
do_setcursor(cursor_arrow);
|
do_setcursor(cursor_arrow);
|
||||||
|
|
@ -11835,9 +11844,11 @@ static int do_open(int want_new_tool)
|
||||||
{
|
{
|
||||||
/* Let user choose an image: */
|
/* Let user choose an image: */
|
||||||
|
|
||||||
draw_tux_text(TUX_BORED,
|
char *freeme =
|
||||||
textdir(gettext_noop("Choose the picture you want, "
|
textdir(gettext_noop("Choose the picture you want, "
|
||||||
"then click “Open”.")), 1);
|
"then click “Open”."));
|
||||||
|
draw_tux_text(TUX_BORED,freeme, 1);
|
||||||
|
free(freeme);
|
||||||
|
|
||||||
/* NOTE: cur is now set above; if file_id'th file is found, it's
|
/* NOTE: cur is now set above; if file_id'th file is found, it's
|
||||||
set to that file's index; otherwise, we default to '0' */
|
set to that file's index; otherwise, we default to '0' */
|
||||||
|
|
@ -13651,6 +13662,7 @@ static char * uppercase(char * str)
|
||||||
sz = sizeof(wchar_t) * (strlen(str) + 1);
|
sz = sizeof(wchar_t) * (strlen(str) + 1);
|
||||||
|
|
||||||
dest = (wchar_t *) malloc(sz);
|
dest = (wchar_t *) malloc(sz);
|
||||||
|
// FIXME: uppercase chars may need extra bytes
|
||||||
ustr = (char *) malloc(sizeof(char) * (strlen(str) + 1));
|
ustr = (char *) malloc(sizeof(char) * (strlen(str) + 1));
|
||||||
|
|
||||||
if (dest != NULL)
|
if (dest != NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue