mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-03 06:47:04 -04:00
security: add missing NULL checks after calloc in LADSPA plugin
Memory Safety: Medium ladspa_plugin_make_desc() calls calloc() twice without checking the return value. If either allocation fails, the code dereferences a NULL pointer, causing a crash. Add NULL checks after both calloc calls and properly free the descriptor struct if the ports allocation fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5f50055750
commit
715d1736e9
1 changed files with 6 additions and 0 deletions
|
|
@ -156,6 +156,8 @@ static const struct spa_fga_descriptor *ladspa_plugin_make_desc(void *plugin, co
|
|||
return NULL;
|
||||
|
||||
desc = calloc(1, sizeof(*desc));
|
||||
if (desc == NULL)
|
||||
return NULL;
|
||||
desc->d = d;
|
||||
|
||||
desc->desc.instantiate = ladspa_instantiate;
|
||||
|
|
@ -172,6 +174,10 @@ static const struct spa_fga_descriptor *ladspa_plugin_make_desc(void *plugin, co
|
|||
|
||||
desc->desc.n_ports = d->PortCount;
|
||||
desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct spa_fga_port));
|
||||
if (desc->desc.ports == NULL) {
|
||||
free(desc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < desc->desc.n_ports; i++) {
|
||||
desc->desc.ports[i].index = i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue