X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=08d14b47fe5f2a803c1703098513035e1724e056;hb=89c6b93ba278e26113aadcc3b7d357e05264beba;hp=e703be400cdaaa0387ae0336884352e6a69c0127;hpb=f18a801e03e50274676544d10029c05e1f219246;p=openocd.git diff --git a/src/helper/command.c b/src/helper/command.c index e703be400c..08d14b47fe 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -83,17 +83,21 @@ static struct log_capture_state *command_log_capture_start(Jim_Interp *interp) { /* capture log output and return it. A garbage collect can * happen, so we need a reference count to this object */ - Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0); - if (NULL == tclOutput) + Jim_Obj *jim_output = Jim_NewStringObj(interp, "", 0); + if (!jim_output) return NULL; + Jim_IncrRefCount(jim_output); + struct log_capture_state *state = malloc(sizeof(*state)); - if (NULL == state) + if (!state) { + LOG_ERROR("Out of memory"); + Jim_DecrRefCount(interp, jim_output); return NULL; + } state->interp = interp; - Jim_IncrRefCount(tclOutput); - state->output = tclOutput; + state->output = jim_output; log_add_callback(tcl_output, state);