Skip to content
Snippets Groups Projects
Commit 07dfa8e1 authored by Evangelos Foutras's avatar Evangelos Foutras :cat:
Browse files

Implement alternate fix for crash on upload (#11879)

The original fix complicated the code by individually allocating GValue
objects and then storing pointers to them in the job parameters array.

While the crash on upload was fixed, the program would still crash on
exit due to the clear_func used for the array (g_free); as per GLib's
documentation, "clear_func is expected to clear the contents of the
array element it is given, but not free the element itself".

The minimal fix in this commit should fix the original issue, and also
the crash on program exit (bug #13684).
parent 3fb61ff1
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,6 @@ screenshooter_simple_job_launch (ScreenshooterSimpleJobFunc func,
{
ScreenshooterSimpleJob *simple_job;
va_list var_args;
GValue value = { 0, };
gchar *error_message;
guint n;
......@@ -164,11 +163,14 @@ screenshooter_simple_job_launch (ScreenshooterSimpleJobFunc func,
simple_job = g_object_new (SCREENSHOOTER_TYPE_SIMPLE_JOB, NULL);
simple_job->func = func;
simple_job->param_values = g_array_sized_new (FALSE, FALSE, sizeof(GValue), n_param_values);
g_array_set_clear_func (simple_job->param_values, (GDestroyNotify) g_value_unset);
/* collect the parameters */
va_start (var_args, n_param_values);
for (n = 0; n < n_param_values; ++n)
{
GValue value = { 0 };
/* initialize the value to hold the next parameter */
g_value_init (&value, va_arg (var_args, GType));
......@@ -183,7 +185,6 @@ screenshooter_simple_job_launch (ScreenshooterSimpleJobFunc func,
}
g_array_append_val(simple_job->param_values, value);
g_value_unset (&value);
}
va_end (var_args);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment