* gsignal.c: fix logic
- From: Tim Janik <timj gtk org>
- To: Elliot Lee <sopwith cuc edu>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: * gsignal.c: fix logic
- Date: Wed, 29 Nov 2000 13:37:29 +0100 (CET)
hi sopwith,
2000-11-28  Elliot Lee  <sopwith redhat com>
        * gsignal.c: Fix warnings about possible use of uninitialized
        variables, and fix logic that would leave 'node' unset in cases
        that it might be used in.
        * glib-genmarshal.c: Fix warning about printf format.
+++ gsignal.c   2000/11/28 23:44:20     1.12
@@ -376,9 +376,9 @@
     {
       HandlerList *hlist = handler_list_lookup (signal_id, instance);
       Handler *handler;
-      SignalNode *node;
+      SignalNode *node = NULL;
-      if (mask & G_SIGNAL_MATCH_FUNC)
+      if (!(mask & G_SIGNAL_MATCH_FUNC))
        {
          node = LOOKUP_SIGNAL_NODE (signal_id);
the code now reads:
  if (mask & G_SIGNAL_MATCH_ID)
    {
      HandlerList *hlist = handler_list_lookup (signal_id, instance);
      Handler *handler;
      SignalNode *node = NULL;
      if (!(mask & G_SIGNAL_MATCH_FUNC))
        {
          node = LOOKUP_SIGNAL_NODE (signal_id);
          if (!node || !node->c_marshaller)
            return NULL;
        }
      mask = ~mask;
      for (handler = hlist ? hlist->handlers : NULL; handler; handler = handler->next)
        if (handler->id &&
            ((mask & G_SIGNAL_MATCH_DETAIL) || handler->detail == detail) &&
            ((mask & G_SIGNAL_MATCH_CLOSURE) || handler->closure == closure) &&
            ((mask & G_SIGNAL_MATCH_DATA) || handler->closure->data == data) &&
            ((mask & G_SIGNAL_MATCH_UNBLOCKED) || handler->block_count == 0) &&
            ((mask & G_SIGNAL_MATCH_FUNC) || (handler->closure->marshal == node->c_marshaller &&
                                              handler->closure->meta_marshal == 0 &&
                                              ((GCClosure*) handler->closure)->callback == func)))
suppose we have mask = (G_SIGNAL_MATCH_ID|G_SIGNAL_MATCH_FUNC);
that gets past the first if(), and then due to your new check, we end
up with node=NULL after the second if, since the body of
if (!(mask & G_SIGNAL_MATCH_FUNC)) is not going to be executed.
then we have mask = ~mask; i.e. (mask&G_SIGNAL_MATCH_FUNC)==0, therefore
if(...((mask & G_SIGNAL_MATCH_FUNC) ||
       (handler->closure->marshal == node->c_marshaller...
is trying to access node->c_marshaller with node being NULL.
---
ciaoTJ
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]