We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 959cd16 commit 28e95b3Copy full SHA for 28e95b3
src/patchelf.h
@@ -2,6 +2,7 @@
2
#include <memory>
3
#include <optional>
4
#include <set>
5
+#include <stdexcept>
6
#include <string>
7
#include <vector>
8
@@ -157,11 +158,14 @@ class ElfFile
157
158
constexpr I rdi(I i) const noexcept;
159
160
/* Convert back to the ELF representation. */
- template<class I>
161
- constexpr I wri(I & t, unsigned long long i) const
+ template<class I, class U>
162
+ constexpr inline I wri(I & t, U i) const
163
{
- t = rdi((I) i);
164
- return i;
+ I val = static_cast<I>(i);
165
+ if (static_cast<U>(val) != i)
166
+ throw std::runtime_error { "value truncation" };
167
+ t = rdi(val);
168
+ return val;
169
}
170
171
[[nodiscard]] Elf_Ehdr *hdr() noexcept {
0 commit comments