From d90d409d2c8dfa017b978f3dfef6b3f698dd723b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 28 Jun 2020 18:48:38 +0900 Subject: [PATCH] [ruamoko] Handle 0-length @va_list for va_copy Fixes a progs crash when using vsprintf with no format elements + params. --- libs/ruamoko/rua_runtime.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/ruamoko/rua_runtime.c b/libs/ruamoko/rua_runtime.c index 697fc720b..24a8a894d 100644 --- a/libs/ruamoko/rua_runtime.c +++ b/libs/ruamoko/rua_runtime.c @@ -56,8 +56,13 @@ bi_va_copy (progs_t *pr) __auto_type src_list = &G_STRUCT (pr, pr_type_t, src_args->list); size_t parm_size = pr->pr_param_size * sizeof(pr_type_t); size_t size = src_args->count * parm_size; - string_t dst_list_block = PR_AllocTempBlock (pr, size); - __auto_type dst_list = (pr_type_t *) PR_GetString (pr, dst_list_block); + string_t dst_list_block = 0; + pr_type_t *dst_list = 0; + + if (size) { + dst_list_block = PR_AllocTempBlock (pr, size); + dst_list = (pr_type_t *) PR_GetString (pr, dst_list_block); + } memcpy (dst_list, src_list, size); R_PACKED (pr, pr_va_list_t).count = src_args->count;