eventscript: fix bug when script is aborted
[sahlberg/ctdb.git] / server / eventscript.c
index 481b47a97ac6e880caa7a6779634b9364a5478dd..9ce9cee484401ff42a3cd3993b079e5f4a2458dd 100644 (file)
@@ -87,9 +87,16 @@ static void log_event_script_output(const char *str, uint16_t len, void *p)
 {
        struct ctdb_event_script_state *state
                = talloc_get_type(p, struct ctdb_event_script_state);
-       struct ctdb_script_wire *current = get_current_script(state);
+       struct ctdb_script_wire *current;
        unsigned int slen, min;
 
+       /* We may have been aborted to run something else.  Discard */
+       if (state->scripts == NULL) {
+               return;
+       }
+
+       current = get_current_script(state);
+
        /* Append, but don't overfill buffer.  It starts zero-filled. */
        slen = strlen(current->output);
        min = MIN(len, sizeof(current->output) - slen - 1);