From fef81140de87ebd703ffc8b89148a8674de0504b Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Tue, 12 Nov 2024 09:15:10 +0100 Subject: [PATCH] Add out-of-bounds assertions --- spirv_cross_parsed_ir.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spirv_cross_parsed_ir.cpp b/spirv_cross_parsed_ir.cpp index 188c0ae65..b05afeb3f 100644 --- a/spirv_cross_parsed_ir.cpp +++ b/spirv_cross_parsed_ir.cpp @@ -928,6 +928,8 @@ void ParsedIR::reset_all_of_type(Types type) void ParsedIR::add_typed_id(Types type, ID id) { + assert(id < ids.size()); + if (loop_iteration_depth_hard != 0) SPIRV_CROSS_THROW("Cannot add typed ID while looping over it."); @@ -1030,6 +1032,8 @@ ParsedIR::LoopLock &ParsedIR::LoopLock::operator=(LoopLock &&other) SPIRV_CROSS_ void ParsedIR::make_constant_null(uint32_t id, uint32_t type, bool add_to_typed_id_set) { + assert(id < ids.size()); + auto &constant_type = get(type); if (constant_type.pointer)