Skip to content

Commit a33f04d

Browse files
committed
fix aliasing UB
1 parent b72e773 commit a33f04d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/dictBuilder/cover.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ pub(super) fn COVER_checkTotalCompressedSize(
967967
}
968968

969969
pub(super) fn COVER_best_wait(
970-
best: &mut COVER_best_t,
970+
best: &COVER_best_t,
971971
) -> std::sync::MutexGuard<'_, COVER_best_t_inner> {
972972
let mut guard = best.mutex.lock().unwrap();
973973
while guard.liveJobs != 0 {
@@ -1320,7 +1320,7 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_cover(
13201320
if displayLevel >= 1 {
13211321
eprintln!("Failed to initialize context");
13221322
}
1323-
drop(COVER_best_wait(&mut best));
1323+
drop(COVER_best_wait(&best));
13241324
POOL_free(pool);
13251325
return initVal;
13261326
}
@@ -1361,7 +1361,7 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_cover(
13611361
}
13621362
drop(data);
13631363
} else {
1364-
COVER_best_start(data.best);
1364+
COVER_best_start(&best);
13651365
if !pool.is_null() {
13661366
POOL_add(
13671367
pool,
@@ -1385,15 +1385,15 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_cover(
13851385
}
13861386
}
13871387

1388-
drop(COVER_best_wait(&mut best));
1388+
drop(COVER_best_wait(&best));
13891389
COVER_ctx_destroy(&mut ctx);
13901390
}
13911391

13921392
if displayLevel >= 2 {
13931393
println!("\r{:79 }\r", "");
13941394
}
13951395

1396-
let best = COVER_best_wait(&mut best);
1396+
let best = COVER_best_wait(&best);
13971397

13981398
let dictSize = best.dictSize;
13991399
if ERR_isError(best.compressedSize) {

lib/dictBuilder/fastcover.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_fastCover(
787787
if displayLevel >= 1 {
788788
eprintln!("Failed to initialize context");
789789
}
790-
drop(COVER_best_wait(&mut best));
790+
drop(COVER_best_wait(&best));
791791
POOL_free(pool);
792792
return initVal;
793793
}
@@ -806,7 +806,7 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_fastCover(
806806
if displayLevel >= 1 {
807807
eprintln!("Failed to allocate parameters");
808808
}
809-
drop(COVER_best_wait(&mut best));
809+
drop(COVER_best_wait(&best));
810810
FASTCOVER_ctx_destroy(&mut ctx);
811811
POOL_free(pool);
812812
return Error::memory_allocation.to_error_code();
@@ -856,15 +856,15 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_fastCover(
856856
}
857857
k = k.wrapping_add(kStepSize);
858858
}
859-
drop(COVER_best_wait(&mut best));
859+
drop(COVER_best_wait(&best));
860860
FASTCOVER_ctx_destroy(&mut ctx);
861861
d = d.wrapping_add(2);
862862
}
863863
if displayLevel >= 2 {
864864
println!("\r{:79 }\r", "");
865865
}
866866

867-
let best = COVER_best_wait(&mut best);
867+
let best = COVER_best_wait(&best);
868868

869869
let dictSize = best.dictSize;
870870
if ERR_isError(best.compressedSize) {

0 commit comments

Comments
 (0)