From 5b5794db23486b640662c6eefbf83c8dee2c5801 Mon Sep 17 00:00:00 2001 From: borutr Date: Sun, 29 Apr 2007 18:24:00 +0000 Subject: [PATCH] * src/SDCCval.c: fixed bug #1592871: Segfault with "large" const arrays of characters replaced recursion with iteration git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4780 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 3 +++ src/SDCCval.c | 36 +++++++++++++++++------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e86ce285..18520c48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2007-04-29 Borut Razem * Fixed svn:eol-style and svn:keywords properties + * src/SDCCval.c: fixed bug + #1592871: Segfault with "large" const arrays of characters + replaced recursion with iteration 2007-04-29 Maarten Brock diff --git a/src/SDCCval.c b/src/SDCCval.c index 70b16664..1a802a15 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -273,30 +273,28 @@ list2expr (initList * ilist) void resolveIvalSym (initList * ilist, sym_link * type) { - RESULT_TYPE resultType; + int is_ptr = IS_PTR (type); + RESULT_TYPE resultType = getResultTypeFromType (getSpec (type)); - if (!ilist) - return; - - if (ilist->type == INIT_NODE) + while (ilist) { - if (IS_PTR (type)) - resultType = RESULT_TYPE_INT; - else - resultType = getResultTypeFromType (getSpec (type)); - ilist->init.node = decorateType (resolveSymbols (ilist->init.node), - resultType); - } - - if (ilist->type == INIT_DEEP) - resolveIvalSym (ilist->init.deep, type); + if (ilist->type == INIT_NODE) + { + ilist->init.node = decorateType (resolveSymbols (ilist->init.node), + is_ptr ? RESULT_TYPE_INT : resultType); + } + else if (ilist->type == INIT_DEEP) + { + resolveIvalSym (ilist->init.deep, type); + } - resolveIvalSym (ilist->next, type); + ilist = ilist->next; + } } -/*-----------------------------------------------------------------*/ -/* symbolVal - creates a value for a symbol */ -/*-----------------------------------------------------------------*/ +/*------------------------------------------------------------------*/ +/* symbolVal - creates a value for a symbol */ +/*------------------------------------------------------------------*/ value * symbolVal (symbol * sym) { -- 2.30.2