From 0c844fc342ec81351128a5402cc7cdc598baa254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 15 Jan 2024 15:11:04 +0800 Subject: [PATCH] FFstrbuf: don't crash with `ffStrbufInitStatic(&buf, NULL)` --- src/util/FFstrbuf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/FFstrbuf.h b/src/util/FFstrbuf.h index 7f67126af..1eb6a3edd 100644 --- a/src/util/FFstrbuf.h +++ b/src/util/FFstrbuf.h @@ -223,6 +223,8 @@ FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate() static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) { ffStrbufInit(strbuf); + if (!str) return; + strbuf->allocated = 0; strbuf->length = (uint32_t) strlen(str); strbuf->chars = (char*) str;