From 4ac8383db19c86cba1bffade7a37a27d77d0f5d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Wed, 16 Apr 1997 13:49:02 -0700
Subject: [PATCH] reference bug fixed

Rev: src/array.c:1.9
Rev: src/svalue.c:1.11
---
 src/array.c  |  3 ++-
 src/svalue.c | 15 ++++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/array.c b/src/array.c
index 4be78178b7..5ec1df37e6 100644
--- a/src/array.c
+++ b/src/array.c
@@ -262,6 +262,7 @@ static struct array *resize_array(struct array *a, INT32 size)
   if(size > a->size)
   {
     /* We should grow the array */
+
     if(a->malloced_size >= size)
     {
       for(;a->size < size; a->size++)
@@ -274,7 +275,7 @@ static struct array *resize_array(struct array *a, INT32 size)
       return a;
     }else{
       struct array *ret;
-      ret=allocate_array_no_init(size, (size>>3)+1);
+      ret=low_allocate_array(size, (size>>3)+1);
       MEMCPY(ITEM(ret),ITEM(a),sizeof(struct svalue)*a->size);
       ret->type_field = a->type_field | BIT_INT;
       a->size=0;
diff --git a/src/svalue.c b/src/svalue.c
index 31261d67b5..be0e092c05 100644
--- a/src/svalue.c
+++ b/src/svalue.c
@@ -178,20 +178,29 @@ void assign_svalues_no_free(struct svalue *to,
 			    INT32 num,
 			    INT32 type_hint)
 {
-  if((type_hint & ~(BIT_INT | BIT_FLOAT))==0)
+#ifdef DEBUG
+  if(d_flag)
+  {
+    INT32 e,t;
+    for(t=e=0;e<num;e++) t|=1<<from[e].type;
+    if(t & ~type_hint)
+      fatal("Type hint lies!\n");
+  }
+#endif
+  if((type_hint & ((2<<MAX_REF_TYPE)-1)) == 0)
   {
     MEMCPY((char *)to, (char *)from, sizeof(struct svalue) * num);
     return;
   }
 
-  if(((type_hint & (BIT_INT | BIT_FLOAT))==0))
+  if((type_hint & ((2<<MAX_REF_TYPE)-1)) == type_hint)
   {
     while(--num >= 0)
     {
       struct svalue tmp;
       tmp=*(from++);
       *(to++)=tmp;
-      tmp.u.refs++;
+      tmp.u.refs[0]++;
     }
     return;
   }
-- 
GitLab