--- a/src/types/IntegerDataTypeReader.h Tue Dec 10 19:37:50 2019 +0100
+++ b/src/types/IntegerDataTypeReader.h Fri Dec 13 22:19:39 2019 +0100
@@ -38,14 +38,14 @@
using namespace relpipe::reader;
/**
- * Unsigned variable-length integer.
- * ULEB128
+ * Signed variable-length integer.
+ * LEB128
*/
class IntegerDataTypeReader : public DataTypeReader<integer_t> {
private:
- uint8_t readNextOctet(std::istream &input) {
- uint8_t value = input.get();
+ octet_t readNextOctet(std::istream &input) {
+ octet_t value = input.get();
if (input.good()) return value;
else throw RelpipeReaderException(L"Unable to read next octet of the integer.");
}
@@ -64,6 +64,9 @@
value += integer_t(octet & 0x7F) << shift;
shift += 7;
} while (octet >= 128);
+
+ if ((shift < (sizeof (integer_t) * 8)) && (octet & 0x40))
+ value |= (~0 << shift);
return value;
}