Skip to content

Commit 73a5d5d

Browse files
ehussweihanglo
authored andcommitted
Add test for dereference of an empty Buf
1 parent ce56683 commit 73a5d5d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/buf.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ impl Drop for Buf {
7575
unsafe { raw::git_buf_dispose(&mut self.raw) }
7676
}
7777
}
78+
79+
#[test]
80+
fn empty_buf() {
81+
let mut buf = Buf::new();
82+
let x: &[u8] = &*buf;
83+
assert_eq!(x.len(), 0);
84+
let x: &mut [u8] = &mut *buf;
85+
assert_eq!(x.len(), 0);
86+
}

0 commit comments

Comments
 (0)