* src/SDCCval.c: fixed bug
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 29 Apr 2007 18:24:00 +0000 (18:24 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 29 Apr 2007 18:24:00 +0000 (18:24 +0000)
  #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
src/SDCCval.c

index e86ce285027991f7718028465bf760c1c52cf88f..18520c48297e76b6b5ad22da6d8d70f4bc4dc2a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2007-04-29 Borut Razem <borut.razem AT siol.net>
 
        * 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 <sourceforge.brock AT dse.nl>
 
index 70b166647529b791597009e4f7f1c606e8fb47d8..1a802a15b500dad1eea2735f1fbe10589cfe9515 100644 (file)
@@ -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)
 {