Skip to content

Commit bdb6ff8

Browse files
authored
Keep gguflib input-validation asserts active in release builds (#3436)
1 parent 894c948 commit bdb6ff8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

mlx/io/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if(MLX_BUILD_GGUF)
1717
PRIVATE $<BUILD_INTERFACE:${gguflib_SOURCE_DIR}>)
1818
add_library(gguflib STATIC ${gguflib_SOURCE_DIR}/fp16.c
1919
${gguflib_SOURCE_DIR}/gguflib.c)
20+
# gguflib uses assert() to reject malformed tensor headers (e.g. ndim > 8).
21+
# Those checks are otherwise compiled out by -DNDEBUG in release builds, which
22+
# leaves out-of-bounds reads/writes unguarded when loading untrusted GGUF
23+
# files. Force NDEBUG off for this target so the asserts stay live.
24+
target_compile_options(gguflib PRIVATE -UNDEBUG)
2025
target_link_libraries(mlx PRIVATE $<BUILD_INTERFACE:gguflib>)
2126
target_sources(mlx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/gguf.cpp
2227
${CMAKE_CURRENT_SOURCE_DIR}/gguf_quants.cpp)

0 commit comments

Comments
 (0)