Another corner case when we terminate running monitor scripts to run
something else: logging can flush the output and we write to a NULL
pointer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
{
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);