security: add missing NULL check after calloc in plugin_builtin

Memory Safety: Medium

In the fallback code path when spa-plugins support is not compiled in,
calloc() for the output sample buffer was not checked for NULL. If the
allocation fails (e.g., due to a large n_samples value from filter
configuration), spa_memcpy would dereference a NULL pointer.

Fixed by adding a NULL check and returning NULL on allocation failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-28 12:35:48 +02:00
parent 1de8615caf
commit 08efbf2254

View file

@ -1014,6 +1014,8 @@ error:
#else
spa_log_error(impl->log, "compiled without spa-plugins support, can't resample");
float *out_samples = calloc(*n_samples, sizeof(float));
if (out_samples == NULL)
return NULL;
spa_memcpy(out_samples, samples, *n_samples * sizeof(float));
return out_samples;
#endif