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 {
13
13
14
14
unsafe {
15
15
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
+ }
17
21
}
18
22
}
19
23
}
Original file line number Diff line number Diff line change @@ -115,7 +115,9 @@ mod editable {
115
115
) where
116
116
T : IsA < Editable > ,
117
117
{
118
- let buf = if new_text_length != -1 {
118
+ let buf = if new_text_length == 0 {
119
+ & [ ]
120
+ } else if new_text_length != -1 {
119
121
slice:: from_raw_parts ( new_text as * mut c_uchar , new_text_length as usize )
120
122
} else {
121
123
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 {
223
223
let f: & F = & * ( f as * const F ) ;
224
224
let mut location_copy = from_glib_none ( location) ;
225
225
226
+ let text = if len <= 0 {
227
+ & [ ]
228
+ } else {
229
+ slice:: from_raw_parts ( text as * const u8 , len as usize )
230
+ } ;
231
+
226
232
f (
227
233
TextBuffer :: from_glib_borrow ( this) . unsafe_cast_ref ( ) ,
228
234
& 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 ( ) ,
230
236
) ;
231
237
232
238
* location = * location_copy. to_glib_none ( ) . 0 ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ impl TreePath {
14
14
mut_override ( self . to_glib_none ( ) . 0 ) ,
15
15
& mut count,
16
16
) ;
17
- if ptr. is_null ( ) {
17
+ if ptr. is_null ( ) || count == 0 {
18
18
vec ! [ ]
19
19
} else {
20
20
slice:: from_raw_parts ( ptr, count as usize ) . to_owned ( )
You can’t perform that action at this time.
0 commit comments