Re: Get/Put Survey

From: George (greerga@circlemud.org)
Date: 01/25/99


On Fri, 22 Jan 1999, Richard Glover wrote:

>I just want to see how many people get the same error that I do.  Use the
>stock CircleMUD30bpl15 compile and run it then load up some objects and a
>bag.  Then, with the objects in your inventory (duh :P), type:
>
>put x in bag
>
>and
>
>get x from bag
>
>Replace x with whatever objects you loaded and make sure to use the 'in' and
>'from'.  It always crashes on my machine(s) because of the half_chop().
>George doesn't have the same problem and is using the same code.  I'm
>wondering if it is machine specific (or user specific :P), so please report
>your findings and the machine/os you are on.

I finally reproduced it.  I couldn't before because it depends on how your
stack lines up and I was probably doing it on a Solaris machine at the
time.  Anyway, it's caused by generic_find() indirectly:

-- 8< ---
  one_argument(arg, name);
  if (!*name)
    return (0);

  *tar_ch = NULL;
  *tar_obj = NULL;
-- 8< ---

However, one_argument("in") == "", so we never had the NULL'ing called.
That left the pointers in do_get and do_put in a random state.  That's why
I could get "in is not a container" and you'd crash.  So I fixed the
underlying generic_find() bug and also modified the do_get/do_put to use
one/two_arguments.

Index: act.item.c

RCS file: /home/jelson/.cvs/circle/src/act.item.c,v
retrieving revision 1.21
diff -u -p -r1.21 act.item.c
--- act.item.c  1998/12/15 06:45:20     1.21
+++ act.item.c  1999/01/25 17:40:54
@@ -108,9 +108,8 @@ ACMD(do_put)
   int obj_dotmode, cont_dotmode, found = 0, howmany = 1;
   char *theobj, *thecont;

-  half_chop(argument, arg1, argument);
-  half_chop(argument, arg2, argument);
-  half_chop(argument, arg3, argument);
+  argument = two_arguments(argument, arg1, arg2);
+  one_argument(argument, arg3);

   if (*arg3 && is_number(arg1)) {
     howmany = atoi(arg1);
@@ -349,9 +348,8 @@ ACMD(do_get)
   struct obj_data *cont;
   struct char_data *tmp_char;

-  half_chop(argument, arg1, argument);
-  half_chop(argument, arg2, argument);
-  half_chop(argument, arg3, argument);
+  argument = two_arguments(argument, arg1, arg2);
+  one_argument(argument, arg1);

   if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch))
     send_to_char("Your arms are already full!\r\n", ch);
Index: handler.c

RCS file: /home/jelson/.cvs/circle/src/handler.c,v
retrieving revision 1.15
diff -u -p -r1.15 handler.c
--- handler.c   1998/12/15 06:56:53     1.15
+++ handler.c   1999/01/25 17:39:10
@@ -1187,13 +1187,13 @@ int generic_find(char *arg, bitvector_t
   int i, found;
   char name[256];

+  *tar_ch = NULL;
+  *tar_obj = NULL;
+
   one_argument(arg, name);

   if (!*name)
     return (0);
-
-  *tar_ch = NULL;
-  *tar_obj = NULL;

   if (IS_SET(bitvector, FIND_CHAR_ROOM)) {     /* Find person in room */
     if ((*tar_ch = get_char_room_vis(ch, name)) != NULL)

Committing shortly.

--
George Greer
greerga@circlemud.org
http://mouse.van.ml.org/


     +------------------------------------------------------------+
     | 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