]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-event: Don't replace an existing result with NULL
authorMartin Schwenke <mschwenke@ddn.com>
Fri, 26 Sep 2025 05:58:26 +0000 (15:58 +1000)
committerRalph Boehme <slow@samba.org>
Tue, 7 Oct 2025 10:08:34 +0000 (10:08 +0000)
If script_list is NULL then event->script_list is set to NULL by
TALLOC_FREE().  This seems like the wrong thing to do because NULL
indicates a problem running the current event.  We should keep the
previous result because it contains useful information.

In theory, this can't happen because the caller checks for NULL.
However, given that the check is here, it might as well do the right
thing... and this simplifies a subsequent change.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
ctdb/event/event_context.c

index 79bcd834576b09f0c72d880c4e4777694c388088..e26d9ae4d1c048d663b1cb4a59c37026f6aa8593 100644 (file)
@@ -141,11 +141,14 @@ static int eventd_event_set(struct event_component *comp,
                return ret;
        }
 
-       TALLOC_FREE(event->script_list);
-       if (script_list != NULL) {
-               event->script_list = talloc_steal(event, script_list);
+       /* Don't replace previous result with a failed one */
+       if (script_list == NULL) {
+               return 0;
        }
 
+       TALLOC_FREE(event->script_list);
+       event->script_list = talloc_steal(event, script_list);
+
        return 0;
 }