Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit cb9be25874b98d1d1e3f531a4a78eefa9f22833d
parent bbaf1bf827a0d8042146eda67434e8eb5966521a
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Tue, 22 Mar 2022 16:25:49 +0000

type_is_castable: fix dangling stack pointer

When to or from have nonzero flags, strip_flags will cause them to point
to the stack. lower_const's arguments both need to be heap-allocated, so
pass the original pointers in.

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Msrc/types.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/types.c b/src/types.c @@ -904,6 +904,7 @@ type_is_castable(const struct type *to, const struct type *from) } struct type _to, _from; + const struct type *to_orig = to, *from_orig = from; to = strip_flags(to, &_to), from = strip_flags(from, &_from); if (to->id == from->id) { return true; @@ -913,7 +914,7 @@ type_is_castable(const struct type *to, const struct type *from) case STORAGE_FCONST: case STORAGE_ICONST: case STORAGE_RCONST: - return lower_const(from, to); + return lower_const(from_orig, to_orig); case STORAGE_I8: case STORAGE_I16: case STORAGE_I32: