File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ unsafe fn ZDICT_tryMerge(
518518}
519519
520520unsafe fn ZDICT_removeDictItem ( table : * mut DictItem , id : u32 ) {
521+ debug_assert_ne ! ( id, 0 ) ;
521522 if id == 0 {
522523 return ; // protection, should never happen
523524 }
@@ -1414,6 +1415,8 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
14141415 let pos = ( * dictList. offset ( u as isize ) ) . pos ;
14151416 let length = ( * dictList. offset ( u as isize ) ) . length ;
14161417 let printedLength = Ord :: min ( 40 , length) ;
1418+
1419+ debug_assert ! ( ( pos + length) as size_t <= samplesBuffSize) ;
14171420 if pos as size_t > samplesBuffSize
14181421 || pos. wrapping_add ( length) as size_t > samplesBuffSize
14191422 {
@@ -1504,6 +1507,7 @@ unsafe fn ZDICT_trainFromBuffer_unsafe_legacy(
15041507 for u in 1 ..( * dictList) . pos {
15051508 let l = ( * dictList. offset ( u as isize ) ) . length ;
15061509 ptr = ptr. offset ( -( l as isize ) ) ;
1510+ debug_assert ! ( ptr >= dictBuffer as * mut u8 ) ;
15071511 if ptr < dictBuffer as * mut u8 {
15081512 free ( dictList as * mut core:: ffi:: c_void ) ;
15091513 return Error :: GENERIC . to_error_code ( ) ; // should not happen
You can’t perform that action at this time.
0 commit comments