filter: return error if id cannot be dereferenced

If an ID cannot be de-referenced, e.g., because the builder buffer is
too small, spa_pod_filter() still reports success, but the result is
NULL. Any subsequent access to result will cause a segfault.

Return an error if no pod is found to properly propagate and handle the
error.

The segfault can be reproduced by using the v4l2 module with Vivid
devices [0], because the buffer for the v4l2 controls is too small.

[0] https://github.com/PipeWire/pipewire/issues/138
This commit is contained in:
Michael Tretter 2019-06-28 14:00:36 +02:00 committed by Wim Taymans
parent 5fa7630934
commit 94ffe88b65

View file

@ -359,6 +359,8 @@ spa_pod_filter(struct spa_pod_builder *b,
if (filter == NULL) {
spa_pod_builder_raw_padded(b, pod, SPA_POD_SIZE(pod));
*result = (struct spa_pod*)b->data;
if (!*result)
return -EINVAL;
return 0;
}