From 156bb05a15b9e58acf88b138185d5cb2068dad88 Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Tue, 21 Apr 2026 09:22:06 +0200 Subject: [PATCH] fix: check `unpack_callback_uint32` result (#666) Similar to #665, just a return value check to propagate the error in case one happens (instead of silently ignoring it). Note that as opposed to the previous lines, we don't need to `PyErr_SetString` since `unpack_callback_uint32` calls `PyLong_FromSize_t` which itself should set whatever Python error is relevant; we just need to make it clear to the caller that an error occurred. --- msgpack/unpack_container_header.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/msgpack/unpack_container_header.h b/msgpack/unpack_container_header.h index c14a3c2..e48d43b 100644 --- a/msgpack/unpack_container_header.h +++ b/msgpack/unpack_container_header.h @@ -45,7 +45,10 @@ static inline int unpack_container_header(unpack_context* ctx, const char* data, PyErr_SetString(PyExc_ValueError, "Unexpected type header on stream"); return -1; } - unpack_callback_uint32(&ctx->user, size, &ctx->stack[0].obj); + + if (unpack_callback_uint32(&ctx->user, size, &ctx->stack[0].obj) < 0) + return -1; + return 1; }