[librsvg: 39/53] Use a proper C string to pass to FcConfigAppFontAddFile




commit 58a348b25767a409c7cb2e9a421defd1f8914954
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Oct 21 19:43:48 2020 -0500

    Use a proper C string to pass to FcConfigAppFontAddFile
    
    str.as_ptr() doesn't have the 0 terminator

 tests/src/utils.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index 305fc7c8..53ccc8a5 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -3,6 +3,7 @@
 use glib::translate::*;
 use libc;
 use std::env;
+use std::ffi::CString;
 use std::path::PathBuf;
 use std::sync::Once;
 
@@ -54,10 +55,11 @@ mod pango_ft2 {
 
         for path in &font_paths {
             let path = fixture_path(path);
-            let str = path.to_str().unwrap();
+            let path_str = path.to_str().unwrap();
+            let path_cstring = CString::new(path_str).unwrap();
 
-            if fontconfig::FcConfigAppFontAddFile(config, str.as_ptr()) == 0 {
-                panic!("Could not load font file {} for tests; aborting", str);
+            if fontconfig::FcConfigAppFontAddFile(config, path_cstring.as_ptr() as *const _) == 0 {
+                panic!("Could not load font file {:?} for tests; aborting", path_str);
             }
         }
 


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