Op 11-10-2025 om 23:00 schreef Lioric Z3:
There is a memory leak path in the preprocessor (file tccpp.c). The traced path
was specifically within the macro argument substitution logic in
macro_arg_subst function, but other paths seem to be affected as well, like
"expr_preprocess" where token string re/allocations are performed as well,
while holding the reallocated pointer in the stack only.

The leak occurs (on the traced path) when a syntax or token error is
encountered during the expansion of a macro argument, and the program exits the
current scope non-locally via an assertion ("expect" assert).

The code path is:
File: tccpp.c
Function: macro_arg_subst
The specific call chain: macro_arg_subst -> tok_str_add2 -> tok_str_realloc -> tal_realloc_impl The error exit: An assertion or token expectation failure, such as expect(...),
which calls tcc_error().

I made a simple testcase:
#define str(x)  #
str()

And compiled with tcc_s (make sani-test creates this).
The output is:
2: error: macro parameter after '#' expected

There are no memory errors reported by the sanitized tcc compiler.

So how can I reproduce this?

    Herman
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to