Commit c059839e authored by Jehan's avatar Jehan

libgimpbase: use g_try_new0() when allocating the parameters.

Basically the number of parameters comes from plug-ins which could write
whatever crap on the wire. I had a case (playing with Python plug-ins)
where GIMP tried to allocate insane amount of parameters. This is bad
as it allows third-party plug-ins to crash GIMP core.

Instead only *try* to allocate, then return as though there were no
parameters if allocation fails. I also print some info on stderr, but
don't output WARNING/CRITICAL (this is not a core error, but a plug-in
error). Fixes:

> GLib-ERROR **: 16:30:23.357: gmem.c:135: failed to allocate 187186442160 bytes
parent 0cfaeb7a
Pipeline #100597 passed with stages
in 50 minutes and 46 seconds
......@@ -1599,7 +1599,21 @@ _gp_params_read (GIOChannel *channel,
*params = g_new0 (GPParam, *nparams);
*params = g_try_new0 (GPParam, *nparams);
/* We may read crap on the wire (and as a consequence try to allocate
* far too much), which would be a plug-in error.
if (*params == NULL)
/* Output on stderr but no WARNING/CRITICAL. This is likely a
* plug-in bug sending bogus data, not a core bug.
g_printerr ("%s: failed to allocate %u parameters\n",
G_STRFUNC, *nparams);
*nparams = 0;
for (i = 0; i < *nparams; i++)
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