coredump: use a fixed string instead a scope-delimited compound literal

The compound literal (const char[]){'.','.','.'} has block scope
(C99 6.5.2.5p6). Once we leave the if and loop back, copy[1].iov_base
formally points into a destroyed object. Works on GCC/Clang in practice,
but is UB.

Let's do the easy thing and use a string.

Reported by qarmin (Rafał Mikrut).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-18 12:44:45 +02:00
parent fd12cc9a52
commit 4f688e61c9
+1 -1
View File
@@ -57,7 +57,7 @@ int coredump_send(CoredumpContext *context) {
* what we want to send, and the second one contains
* the trailing dots. */
copy[0] = *iovec;
copy[1] = IOVEC_MAKE(((const char[]){'.', '.', '.'}), 3);
copy[1] = IOVEC_MAKE_STRING("...");
mh.msg_iov = copy;
mh.msg_iovlen = 2;