Skip to content

Commit 7fc18d3

Browse files
authored
Merge pull request #192 from dbartol/dbartol/int32
Fix display of negative integers in results
2 parents 513d763 + 43549ee commit 7fc18d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/semmle-bqrs/src/bqrs-parse.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,14 @@ async function parsePrimitiveColumn(d: StreamDigester, type: PrimitiveTypeKind,
144144
switch (type) {
145145
case 's': return await parseString(d, pool);
146146
case 'b': return await d.readByte() !== 0;
147-
case 'i': return await d.readLEB128UInt32();
147+
case 'i': {
148+
const unsignedValue = await d.readLEB128UInt32();
149+
// `int` column values are encoded as 32-bit unsigned LEB128, but are really 32-bit two's
150+
// complement signed integers. The easiest way to reinterpret from an unsigned int32 to a
151+
// signed int32 in JavaScript is to use a bitwise operator, which does this coercion on its
152+
// operands automatically.
153+
return unsignedValue | 0;
154+
}
148155
case 'f': return await d.readDoubleLE();
149156
case 'd': return await d.readDate();
150157
case 'u': return await parseString(d, pool);

0 commit comments

Comments
 (0)