mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
log: fix panic when using a log id with a formatted log message
Would panic because of a missing NUL terminator: thread '<unnamed>' panicked at .. glib/src/gstring.rs:61:9: assertion failed: !bytes.is_empty() && bytes[bytes.len() - 1] == 0 3: glib::gstring::GStr::from_utf8_with_nul_unchecked 4: gstreamer::log::DebugCategory::log_id_unfiltered_internal at gstreamer-rs/gstreamer/src/log.rs:465 5: gstreamer::log::DebugCategory::log_id_unfiltered at gstreamer-rs/gstreamer/src/log.rs:425 Also enable logging on the category, so the logging code paths are actually run here in the tests. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1451>
This commit is contained in:
parent
b20ea25147
commit
c545154472
1 changed files with 7 additions and 0 deletions
|
@ -460,6 +460,7 @@ impl DebugCategory {
|
|||
if std::io::Write::write_fmt(&mut w, args).is_err() {
|
||||
return;
|
||||
}
|
||||
w.push(0);
|
||||
|
||||
self.log_id_literal_unfiltered_internal(id, level, file, function, line, unsafe {
|
||||
glib::GStr::from_utf8_with_nul_unchecked(&w)
|
||||
|
@ -1498,8 +1499,14 @@ mod tests {
|
|||
Some("Blablabla"),
|
||||
);
|
||||
|
||||
cat.set_threshold(crate::DebugLevel::Trace);
|
||||
|
||||
trace!(cat, id: "123", "test");
|
||||
trace!(cat, id: glib::GString::from("123"), "test");
|
||||
trace!(cat, id: &glib::GString::from("123"), "test");
|
||||
|
||||
// Try with a formatted string too (which is a different code path in the bindings)
|
||||
let log_id = glib::GString::from("456");
|
||||
trace!(cat, id: &log_id , "{log_id:?}");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue