This repository was archived by the owner on Mar 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,11 @@ impl Visual {
1313
1414 unsafe {
1515 ffi:: gdk_query_depths ( & mut ptr, & mut count) ;
16- Vec :: from ( slice:: from_raw_parts ( ptr as * const i32 , count as usize ) )
16+ if ptr. is_null ( ) || count == 0 {
17+ vec ! [ ]
18+ } else {
19+ Vec :: from ( slice:: from_raw_parts ( ptr as * const i32 , count as usize ) )
20+ }
1721 }
1822 }
1923}
Original file line number Diff line number Diff line change @@ -115,7 +115,9 @@ mod editable {
115115 ) where
116116 T : IsA < Editable > ,
117117 {
118- let buf = if new_text_length != -1 {
118+ let buf = if new_text_length == 0 {
119+ & [ ]
120+ } else if new_text_length != -1 {
119121 slice:: from_raw_parts ( new_text as * mut c_uchar , new_text_length as usize )
120122 } else {
121123 CStr :: from_ptr ( new_text) . to_bytes ( )
Original file line number Diff line number Diff line change @@ -223,10 +223,16 @@ impl<O: IsA<TextBuffer>> TextBufferExtManual for O {
223223 let f: & F = & * ( f as * const F ) ;
224224 let mut location_copy = from_glib_none ( location) ;
225225
226+ let text = if len <= 0 {
227+ & [ ]
228+ } else {
229+ slice:: from_raw_parts ( text as * const u8 , len as usize )
230+ } ;
231+
226232 f (
227233 TextBuffer :: from_glib_borrow ( this) . unsafe_cast_ref ( ) ,
228234 & mut location_copy,
229- str:: from_utf8 ( slice :: from_raw_parts ( text as * const u8 , len as usize ) ) . unwrap ( ) ,
235+ str:: from_utf8 ( text) . unwrap ( ) ,
230236 ) ;
231237
232238 * location = * location_copy. to_glib_none ( ) . 0 ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ impl TreePath {
1414 mut_override ( self . to_glib_none ( ) . 0 ) ,
1515 & mut count,
1616 ) ;
17- if ptr. is_null ( ) {
17+ if ptr. is_null ( ) || count == 0 {
1818 vec ! [ ]
1919 } else {
2020 slice:: from_raw_parts ( ptr, count as usize ) . to_owned ( )
You can’t perform that action at this time.
0 commit comments