Skip to content

Commit eb74a8d

Browse files
Fix debug assert when input lenght is unknown (0)
1 parent d5f3a7f commit eb74a8d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

headers/codecs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class IntegerCODEC {
5353
* of the variable nvalue gets updated with the number actually use
5454
* (if nvalue exceeds the original value, there might be a buffer
5555
* overrun).
56+
*
57+
* NOTE: Decoding can be performed with an unknown input length. This
58+
* case is indicated by a length of 0; however, nvalue must be provided
59+
* in order for the decoder knows how many values to decode.
5660
*/
5761
virtual const uint32_t *decodeArray(const uint32_t *in, const size_t length,
5862
uint32_t *out, size_t &nvalue) = 0;

headers/simple16.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ const uint32_t *Simple16<MarkLength>::decodeArray(const uint32_t *in,
745745
printf("simple16 stats[%u]=%f\n", k, stats[k] * 1.0 / sum);
746746
}
747747
#endif
748-
ASSERT(in <= endin, std::to_string(in - endin));
748+
ASSERT(len == 0 || in <= endin, std::to_string(in - endin));
749749
return in;
750750
}
751751

headers/simple8b.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,9 @@ const uint32_t *Simple8b<MarkLength>::decodeArray(const uint32_t *in,
637637
printf("simple8b stats[%u]=%f\n", k, stats[k] * 1.0 / sum);
638638
}
639639
#endif
640-
assert(in64 <= finalin64);
640+
assert(len == 0 || in64 <= finalin64);
641641
in = reinterpret_cast<const uint32_t *>(in64);
642-
assert(in <= endin);
642+
assert(len == 0 || in <= endin);
643643
// check that we don't overrun the buffer too much?
644644
ASSERT(out < end + 240, std::to_string(out - end));
645645
nvalue = MarkLength ? actualvalue : out - initout;

0 commit comments

Comments
 (0)