Files
eternalwrt-mt798x/package/utils/ucode/patches/101-lib-avoid-allocating-print-buffer-before-NULL-check-.patch
T
Felix Fietkau 7987b1f799 ucode: fix two compiler issues
- When working with deeply nested imports, compile errors led to long
  error messages or complete hangs by compiling the same module over
  and over again.
- Fix for a function expression scope issue.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-07-07 10:46:12 +02:00

32 lines
772 B
Diff

From: Felix Fietkau <nbd@nbd.name>
Date: Tue, 7 Jul 2026 09:34:16 +0200
Subject: [PATCH] lib: avoid allocating print buffer before NULL check in
uc_error_message_indent
Move the print buffer allocation after the guard that returns early on a
NULL message, so no buffer is allocated on that path. This keeps the
function leak-free when callers invoke it without having produced an error
string.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/lib.c
+++ b/lib.c
@@ -220,13 +220,14 @@ uc_error_context_format(uc_stringbuf_t *
void
uc_error_message_indent(char **msg) {
- uc_stringbuf_t *buf = xprintbuf_new();
+ uc_stringbuf_t *buf;
char *s, *p, *nl;
size_t len;
if (!msg || !*msg)
return;
+ buf = xprintbuf_new();
s = *msg;
len = strlen(s);