================ @@ -137,21 +137,21 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) { template <typename T> static void emit(Program &P, std::vector<std::byte> &Code, const T &Val, bool &Success) { + size_t ValPos = Code.size(); size_t Size; if constexpr (std::is_pointer_v<T>) - Size = sizeof(uint32_t); + Size = align(sizeof(uint32_t)); else - Size = sizeof(T); + Size = align(sizeof(T)); - if (Code.size() + Size > std::numeric_limits<unsigned>::max()) { + if (ValPos + Size > std::numeric_limits<unsigned>::max()) { ---------------- shafik wrote:
This does not look like a valid overflow check. Unless we assert both `ValPos` and `Size` are less than or equal to max unsigned. Then the check should really be `ValPos > std::numeric_limits<unsigned>::max() - Size` https://blog.regehr.org/archives/1139 Maybe I am misunderstanding the check. https://github.com/llvm/llvm-project/pull/151824 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits