summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-07-27 09:42:57 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-08 10:55:36 +0200
commitefd1aea969f9580493b41e52dc5f2b1e2d24646d (patch)
tree6324b43e0cbef8892aace2af8607182379557d05 /AK
parenta59b9357e38bb81478dd2fc71ec2c44882492940 (diff)
downloadserenity-efd1aea969f9580493b41e52dc5f2b1e2d24646d.zip
AK: Make `InputMemoryStream::read_LEB128_*` templated
On i686, reading integers larger than `2^32 - 1` would fail as the 32-bit `size_t` parameter would overflow. This caused us to read too few bytes in LibDebug's DWARF parser. Making this method templated solves this issue, as we now can call this API with a `u64` parameter.
Diffstat (limited to 'AK')
-rw-r--r--AK/MemoryStream.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/AK/MemoryStream.h b/AK/MemoryStream.h
index 18ca769768..cd18d5dca4 100644
--- a/AK/MemoryStream.h
+++ b/AK/MemoryStream.h
@@ -74,9 +74,11 @@ public:
return m_bytes[m_offset];
}
- bool read_LEB128_unsigned(size_t& result) { return LEB128::read_unsigned(*this, result); }
+ template<typename ValueType>
+ bool read_LEB128_unsigned(ValueType& result) { return LEB128::read_unsigned(*this, result); }
- bool read_LEB128_signed(ssize_t& result) { return LEB128::read_signed(*this, result); }
+ template<typename ValueType>
+ bool read_LEB128_signed(ValueType& result) { return LEB128::read_signed(*this, result); }
ReadonlyBytes bytes() const { return m_bytes; }
size_t offset() const { return m_offset; }