Fix freeing broker.
authorGuo Rui <firemeteor@Adam.(none)>
Mon, 20 Jul 2009 16:22:12 +0000 (21 00:22 +0800)
committerGuo Rui <firemeteor@Adam.(none)>
Mon, 20 Jul 2009 16:22:12 +0000 (21 00:22 +0800)
src/script.c

index ce035cb..c0473f7 100644 (file)
@@ -368,13 +368,20 @@ get_obj_broker(void *obj)
 
 void * get_broker_obj(struct broker *broker)
 {
+  if (!broker)
+    return NULL;
+
   if (broker->valid)
     return broker->obj;
 
   if (--broker->ref == 0)
     {
-      struct broker **b = broker_from_obj(broker->obj);
-      Free(b);
+      struct broker *n, **b = broker_from_obj(broker->obj);
+      if (*b) {
+         n = (*b)->b_next;
+         free(*b);
+         *b = n;
+      }
     }
   return NULL;
 }