Re: OasisOLC v2.0-pre7 (another bug)

From: George Greer (greerga@circlemud.org)
Date: 05/15/99


On Sat, 15 May 1999, Chris Gilbert wrote:

>Doh, that should be ex_description not action_description, IE:
>  if (obj->ex_description && obj->ex_description !=
>obj_proto[robj_num].ex_description) {
>
>The reason it helps is that it the first time around the loop plist is
>set to obj_proto.ex_description fine, however, it can be freed later by
>the free(thised), so the next time around plist picks up garbage.
>
>The code used to do that when it was in free_obj in db.c, I think it's
>just a cut and paste error...

Try this instead:

diff -up OasisOLCv2.0-pre7/genobj.c OasisOLCv2.0-pre8/genobj.c
--- OasisOLCv2.0-pre7/genobj.c  Fri May 14 03:29:34 1999
+++ OasisOLCv2.0-pre8/genobj.c  Sat May 15 11:06:46 1999
@@ -288,20 +288,23 @@ void free_object_strings_proto(struct ob
     free(obj->action_description);
   if (obj->ex_description) {
     struct extra_descr_data *thised, *plist, *next_one; /* O(horrible) */
-    int ok_key, ok_desc;
+    int ok_key, ok_desc, ok_item;
     for (thised = obj->ex_description; thised; thised = next_one) {
       next_one = thised->next;
-      for (ok_key = ok_desc = 1, plist = obj_proto[robj_num].ex_description; plist; plist = plist->next) {
+      for (ok_item = ok_key = ok_desc = 1, plist = obj_proto[robj_num].ex_description; plist; plist = plist->next) {
         if (plist->keyword == thised->keyword)
           ok_key = 0;
         if (plist->description == thised->description)
           ok_desc = 0;
+        if (plist == thised)
+          ok_item = 0;
       }
       if (thised->keyword && ok_key)
         free(thised->keyword);
       if (thised->description && ok_desc)
         free(thised->description);
-      free(thised);
+      if (ok_item)
+        free(thised);
     }
   }
 }

It may be possible to have unique extra descriptions some day.

--
George Greer            | Sammy's Code - OBuild
greerga@circlemud.org   | http://www.ticnet.com/samedi/code.html


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST