Merge branch 'leak-fix' into 'main'

tests/desktop-app-info: fix stack-use-after-scope

See merge request GNOME/glib!3187
This commit is contained in:
Philip Withnall 2023-01-26 15:36:22 +00:00
commit ac30b7d824

View File

@ -1382,6 +1382,18 @@ typedef struct {
TerminalLaunchType type; TerminalLaunchType type;
} TerminalLaunchData; } TerminalLaunchData;
static TerminalLaunchData *
terminal_launch_data_new (const char *exec, TerminalLaunchType type)
{
TerminalLaunchData *d = NULL;
d = g_new0 (TerminalLaunchData, 1);
d->exec = exec;
d->type = type;
return d;
}
static void static void
test_launch_uris_with_terminal (gconstpointer data) test_launch_uris_with_terminal (gconstpointer data)
{ {
@ -1849,27 +1861,26 @@ main (int argc,
path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-path/%s", path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-path/%s",
supported_terminals[i]); supported_terminals[i]);
g_test_add_data_func (path, &(TerminalLaunchData) { g_test_add_data_func_full (path,
.exec = supported_terminals[i], terminal_launch_data_new (supported_terminals[i],
.type = TERMINAL_LAUNCH_TYPE_COMMAND_LINE_WITH_PATH_OVERRIDE, TERMINAL_LAUNCH_TYPE_COMMAND_LINE_WITH_PATH_OVERRIDE),
}, test_launch_uris_with_terminal); test_launch_uris_with_terminal, g_free);
g_clear_pointer (&path, g_free);
g_free (path);
path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-context/%s", path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-context/%s",
supported_terminals[i]); supported_terminals[i]);
g_test_add_data_func (path, &(TerminalLaunchData) { g_test_add_data_func_full (path,
.exec = supported_terminals[i], terminal_launch_data_new (supported_terminals[i],
.type = TERMINAL_LAUNCH_TYPE_COMMAND_LINE_WITH_CONTEXT, TERMINAL_LAUNCH_TYPE_COMMAND_LINE_WITH_CONTEXT),
}, test_launch_uris_with_terminal); test_launch_uris_with_terminal, g_free);
g_clear_pointer (&path, g_free); g_clear_pointer (&path, g_free);
path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-desktop-path/%s", path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/with-desktop-path/%s",
supported_terminals[i]); supported_terminals[i]);
g_test_add_data_func (path, &(TerminalLaunchData) { g_test_add_data_func_full (path,
.exec = supported_terminals[i], terminal_launch_data_new (supported_terminals[i],
.type = TERMINAL_LAUNCH_TYPE_KEY_FILE_WITH_PATH, TERMINAL_LAUNCH_TYPE_KEY_FILE_WITH_PATH),
}, test_launch_uris_with_terminal); test_launch_uris_with_terminal, g_free);
g_clear_pointer (&path, g_free); g_clear_pointer (&path, g_free);
} }