Quickcheck #1

Merged
merged 12 commits into from May 13, 2016

fix: Avoid compression if there is not enough data

This was found by QuickCheck
commit 5b2e81506e83a797519d5d85c776de296769fdd3 @badboy committed May 12, 2016
View
@@ -63,8 +63,8 @@ pub fn compress(data: &[u8]) -> LzfResult<Vec<u8>> {
let mut current_offset = 0;
- if in_len == 0 {
- return Err(LzfError::DataCorrupted);
+ if in_len < 2 {
+ return Err(LzfError::NoCompressionPossible);
}
let mut lit: i32 = 0;
@@ -259,3 +259,10 @@ fn quickcheck_found_bug() {
assert_eq!(LzfError::NoCompressionPossible, compress(&inp).unwrap_err());
}
+
+#[test]
+fn quickcheck_found_bug2() {
+ let inp = vec![0];
+
+ assert_eq!(LzfError::NoCompressionPossible, compress(&inp).unwrap_err());
+}