From 1518f9041c5c89b2f121b9c162d2fef78d721321 Mon Sep 17 00:00:00 2001 From: cnjhb Date: Mon, 16 Mar 2026 13:56:43 +0800 Subject: [PATCH] chore(xutil): clear compile warnings warning: '__builtin_memcpy' specified bound between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] 29 | return __builtin___memcpy_chk (__dest, __src, __len, --- common/xutil.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/xutil.h b/common/xutil.h index 81820f255e..d0efc8a799 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -40,16 +40,17 @@ xutil_get_text_property_from_reply(xcb_get_property_reply_t *reply) && (reply->type == XCB_ATOM_STRING || reply->type == UTF8_STRING || reply->type == COMPOUND_TEXT) - && reply->format == 8 - && xcb_get_property_value_length(reply)) + && reply->format == 8) { - /* We need to copy it that way since the string may not be - * NULL-terminated */ int len = xcb_get_property_value_length(reply); - char *value = p_new(char, len + 1); - memcpy(value, xcb_get_property_value(reply), len); - value[len] = '\0'; - return value; + if (len > 0) { + /* We need to copy it that way since the string may not be + * NULL-terminated */ + char* value = p_new(char, len + 1); + memcpy(value, xcb_get_property_value(reply), (size_t)len); + value[len] = '\0'; + return value; + } } return NULL; }