With `PW_STREAM_FLAG_ALLOC_BUFFERS`, `fd` field is uninitialized
I noticed this working with pipewire-rs, but you can also see this by modifying src/examples/video-src-alloc.c
with the line printf("fd: %ld\n", d[0].fd);
at the start of on_stream_add_buffer()
, running valgrind ./build/src/examples/video-src-alloc
and connecting to the stream with something like gst-launch-1.0 pipewiresrc path=<node id> ! videoconvert ! waylandsink
.
The field is naturally also uninitialized in the process()
callback if an add_buffer()
isn't used or it doesn't set the field.
All the other fields seem to be initialized. I feel this should probably be initialized to -1
? That way simply printing the fields of the buffer passed to add_buffer()
isn't undefined behavior. And this would help for providing safe Rust bindings, though there are other complications to that.
It should be simple to change this, though grepping through Pipewire I'm not 100% sure which place(s) it would need to be set.