[1178] in Coldmud discussion meeting

root meeting help first previous next last

[COLD] YAP

daemon@ATHENA.MIT.EDU (Fri Dec 13 11:14:09 1996 )

Date: Fri, 13 Dec 1996 17:05:34 +0100 (MET)
From: Miroslav Silovic <Miroslav.Silovic@public.srce.hr>
To: coldstuff@cold.org

Here's Yet Another Patch. :) THe problem is wrong logic in both string_prep
and list_prep. Certain combinations of subrange() and + crashed the
server. I managed to tickle this with routine that unparsed my
debugger output. BTW, consider debugger fully operational, as well.

---------------------------------------------------------------------

diff -C 5 -r Genesis-1.0p19/src/data/list.c Genesis-1.0p19-new/src/data/list.c
*** Genesis-1.0p19/src/data/list.c	Fri Dec 13 17:02:00 1996
--- Genesis-1.0p19-new/src/data/list.c	Fri Dec 13 17:02:00 1996
***************
*** 43,55 ****
               resize,
               size;
  
      /* Figure out if we need to resize the list or move its contents.  Moving
       * contents takes precedence. */
!     resize = (len - start) * 4 < list->size;
!     resize = resize && list->size > STARTING_SIZE;
!     resize = resize || (list->size < len);
  
      /* Move the list contents into a new list. */
      if ((list->refs > 1) || (resize && start > 0)) {
          cnew = list_new(len);
          cnew->len = len;
--- 43,53 ----
               resize,
               size;
  
      /* Figure out if we need to resize the list or move its contents.  Moving
       * contents takes precedence. */
!     resize = list->size < len + start;
  
      /* Move the list contents into a new list. */
      if ((list->refs > 1) || (resize && start > 0)) {
          cnew = list_new(len);
          cnew->len = len;
diff -C 5 -r Genesis-1.0p19/src/data/string.c Genesis-1.0p19-new/src/data/string.c
*** Genesis-1.0p19/src/data/string.c	Fri Dec 13 17:02:00 1996
--- Genesis-1.0p19-new/src/data/string.c	Fri Dec 13 17:02:00 1996
***************
*** 280,292 ****
      cStr *cnew;
      Int need_to_move, need_to_resize, size;
  
      /* Figure out if we need to resize the string or move its contents.  Moving
       * contents takes precedence. */
!     need_to_resize = (len - start) * 4 < str->size;
!     need_to_resize = need_to_resize && str->size > STARTING_SIZE;
!     need_to_resize = need_to_resize || (str->size <= len);
      need_to_move = (str->refs > 1) || (need_to_resize && start > 0);
  
      if (need_to_move) {
          /* Move the string's contents into a new string. */
          cnew = string_new(len);
--- 280,291 ----
      cStr *cnew;
      Int need_to_move, need_to_resize, size;
  
      /* Figure out if we need to resize the string or move its contents.  Moving
       * contents takes precedence. */
!  
!     need_to_resize = str->size <= len + start;
      need_to_move = (str->refs > 1) || (need_to_resize && start > 0);
  
      if (need_to_move) {
          /* Move the string's contents into a new string. */
          cnew = string_new(len);