Fix a segfault reported by Etienne Renault using dve2check.
* src/misc/intvcmp2.cc (stream_compression_base::run): Fix a case where the "id" of the compression to use would be miscalculated, causing wrong values to be encoded. * src/tgbatest/intvcmp2.cc: Add this particular test case.
This commit is contained in:
parent
4b5734d8ec
commit
547715463a
3 changed files with 26 additions and 12 deletions
|
|
@ -1,3 +1,12 @@
|
||||||
|
2012-01-24 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
Fix a segfault reported by Etienne Renault using dve2check.
|
||||||
|
|
||||||
|
* src/misc/intvcmp2.cc (stream_compression_base::run): Fix a case
|
||||||
|
where the "id" of the compression to use would be miscalculated,
|
||||||
|
causing wrong values to be encoded.
|
||||||
|
* src/tgbatest/intvcmp2.cc: Add this particular test case.
|
||||||
|
|
||||||
2012-01-20 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2012-01-20 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
* NEWS: Add missing dates.
|
* NEWS: Add missing dates.
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ namespace spot
|
||||||
// This implements integer compression inspired from "Simple-9".
|
// This implements integer compression inspired from "Simple-9".
|
||||||
//
|
//
|
||||||
// The first bits of an integer tell how the rest of the integer is coded:
|
// The first bits of an integer tell how the rest of the integer is coded:
|
||||||
// 00: 30 1-bit values
|
// 00: 30 1-bit values id=0
|
||||||
// 01: 10 3-bit values
|
// 01: 10 3-bit values id=1
|
||||||
// 10: 6 5-bit values
|
// 10: 6 5-bit values id=2
|
||||||
// 1100: 4 7-bit values
|
// 1100: 4 7-bit values id=3
|
||||||
// 1101: 3 9-bit values (1 bit lost)
|
// 1101: 3 9-bit values (1 bit lost) id=4
|
||||||
// 1110: 2 14-bit values
|
// 1110: 2 14-bit values id=5
|
||||||
// 1111: 1 28-bit value
|
// 1111: 1 28-bit value id=6
|
||||||
|
|
||||||
template <class Self>
|
template <class Self>
|
||||||
class stream_compression_base
|
class stream_compression_base
|
||||||
|
|
@ -94,7 +94,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
unsigned id = 0; // Current level in the above two tables.
|
unsigned id = 0; // Current level in the above two tables.
|
||||||
unsigned curmax_allowed = max_allowed[id];
|
unsigned curmax_allowed = max_allowed[id];
|
||||||
unsigned compressable = 0; // Number of integer ready to pack.
|
unsigned compressable = 0; // Number of integers ready to pack.
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned int val = self().data_at(compressable);
|
unsigned int val = self().data_at(compressable);
|
||||||
|
|
@ -103,17 +103,19 @@ namespace spot
|
||||||
{
|
{
|
||||||
curmax_allowed = max_allowed[++id];
|
curmax_allowed = max_allowed[++id];
|
||||||
|
|
||||||
if (compressable >= max_count[id])
|
if (compressable > max_count[id])
|
||||||
goto fast_encode;
|
goto fast_encode;
|
||||||
}
|
}
|
||||||
|
if (compressable >= max_count[id])
|
||||||
|
goto fast_encode;
|
||||||
}
|
}
|
||||||
while (likely(compressable < max_count[id]
|
while (likely(compressable < size_));
|
||||||
&& compressable < size_));
|
|
||||||
|
|
||||||
assert(compressable <= max_count[id]);
|
assert(compressable < max_count[id]);
|
||||||
|
|
||||||
// Since we have less data than the current "id" allows,
|
// Since we have less data than the current "id" allows,
|
||||||
// try to use more bits so we can encode faster.
|
// try to use more bits so we can encode faster.
|
||||||
|
|
||||||
id = count_to_level[compressable - 1];
|
id = count_to_level[compressable - 1];
|
||||||
|
|
||||||
if (compressable == max_count[id])
|
if (compressable == max_count[id])
|
||||||
|
|
|
||||||
|
|
@ -127,5 +127,8 @@ int main()
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 9 };
|
0, 0, 0, 0, 0, 0, 0, 0, 9 };
|
||||||
errors += check(comp10, sizeof(comp10) / sizeof(*comp10));
|
errors += check(comp10, sizeof(comp10) / sizeof(*comp10));
|
||||||
|
|
||||||
|
int comp11[] = { 2, 254, 254, 0, 1, 4, 0, 0, 0, 1, 0, 1, 253, 0 };
|
||||||
|
errors += check(comp11, sizeof(comp11) / sizeof(*comp11));
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue