[Bug bzip2/28904] libbzip2: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
mark at klomp dot org
sourceware-bugzilla@sourceware.org
Tue Apr 19 22:23:49 GMT 2022
https://sourceware.org/bugzilla/show_bug.cgi?id=28904
--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
A different solution might be to use the constant BZ_N_GROUPS instead of the
variable nGroups when resetting the arrays:
diff --git a/compress.c b/compress.c
index 5dfa002..2dc5dc1 100644
--- a/compress.c
+++ b/compress.c
@@ -321,7 +321,7 @@ void sendMTFValues ( EState* s )
---*/
for (iter = 0; iter < BZ_N_ITERS; iter++) {
- for (t = 0; t < nGroups; t++) fave[t] = 0;
+ for (t = 0; t < BZ_N_GROUPS; t++) fave[t] = 0;
for (t = 0; t < nGroups; t++)
for (v = 0; v < alphaSize; v++)
@@ -353,7 +353,7 @@ void sendMTFValues ( EState* s )
Calculate the cost of this group as coded
by each of the coding tables.
--*/
- for (t = 0; t < nGroups; t++) cost[t] = 0;
+ for (t = 0; t < BZ_N_GROUPS; t++) cost[t] = 0;
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
Which might also help the compiler to simply zero the whole (6 element) arrays
in one go (the common case), instead of having to check whether nGroups is
smaller in this particular case.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Bzip2-devel
mailing list