[librsvg/librsvg-2.48] (#592): Fix invalid argument to g_log_structured_array()



commit be744299097fc939b56eb518cbc9fc0c1bd2fc9b
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Apr 22 13:26:19 2020 -0500

    (#592): Fix invalid argument to g_log_structured_array()
    
    The string wasn't nul-terminated.  Oof.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/592

 librsvg/c_api.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index 03805acb..e4a1790b 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -13,6 +13,7 @@ use glib::error::ErrorDomain;
 use url::Url;
 
 use bitflags::bitflags;
+use libc;
 
 use gio::prelude::*;
 
@@ -1596,6 +1597,9 @@ fn rsvg_g_log(level: glib_sys::GLogLevelFlags, msg: &str) {
         _ => unreachable!("please add another log level priority to rsvg_g_log()"),
     };
 
+    let c_msg = msg.to_glib_none();
+    let c_char_msg: *const libc::c_char = c_msg.0;
+
     // Glib's g_log_structured_standard() adds a few more fields for the source
     // file, line number, etc., but those are not terribly useful without a stack
     // trace.  So, we'll omit them.
@@ -1607,7 +1611,7 @@ fn rsvg_g_log(level: glib_sys::GLogLevelFlags, msg: &str) {
         },
         GLogField {
             key: b"MESSAGE\0" as *const u8 as *const _,
-            value: msg.as_ptr() as *const _,
+            value: c_char_msg as *const _,
             length: msg.len() as _,
         },
         // This is the G_LOG_DOMAIN set from the Makefile


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]