media: ffmpeg: fix undefined behavior in test_avpacket_drop

The AvBufferSource pointer gets converted into a Rust slice, so it is
not valid to use a null pointer (even though the length is 0). Return a
valid pointer derived from an empty slice instead.

BUG=b:365852007

Change-Id: I12930c98241d2d711826c577ae23944ec8d5d93b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6013082
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2024-11-11 14:52:21 -08:00 committed by crosvm LUCI
parent ea6b766072
commit 147b0fe6c2

View file

@ -1041,7 +1041,6 @@ impl Drop for AvFrame {
#[cfg(test)]
mod tests {
use std::ptr;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
@ -1078,7 +1077,7 @@ mod tests {
}
impl AvBufferSource for DropTestBufferSource {
fn as_ptr(&self) -> *const u8 {
ptr::null()
[].as_ptr()
}
fn len(&self) -> usize {