registering a target event twice caused infinite loop. Same bug as in jtag/core.c copy & pasted.

git-svn-id: svn://svn.berlios.de/openocd/trunk@2690 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
oharboe 2009-09-11 06:58:49 +00:00
parent 6dd8f37e6d
commit 58b78818e0
1 changed files with 9 additions and 4 deletions

View File

@ -2,7 +2,7 @@
* Copyright (C) 2005 by Dominic Rath * * Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de * * Dominic.Rath@gmx.de *
* * * *
* Copyright (C) 2007,2008 Øyvind Harboe * * Copyright (C) 2007-2009 Øyvind Harboe *
* oyvind.harboe@zylin.com * * oyvind.harboe@zylin.com *
* * * *
* Copyright (C) 2008, Duane Ellis * * Copyright (C) 2008, Duane Ellis *
@ -3547,9 +3547,11 @@ static int target_configure(Jim_GetOptInfo *goi, target_t *target)
} }
if (goi->isconfigure) { if (goi->isconfigure) {
bool replace = true;
if (teap == NULL) { if (teap == NULL) {
/* create new */ /* create new */
teap = calloc(1, sizeof(*teap)); teap = calloc(1, sizeof(*teap));
replace = false;
} }
teap->event = n->value; teap->event = n->value;
Jim_GetOpt_Obj(goi, &o); Jim_GetOpt_Obj(goi, &o);
@ -3569,9 +3571,12 @@ static int target_configure(Jim_GetOptInfo *goi, target_t *target)
*/ */
Jim_IncrRefCount(teap->body); Jim_IncrRefCount(teap->body);
/* add to head of event list */ if (!replace)
teap->next = target->event_action; {
target->event_action = teap; /* add to head of event list */
teap->next = target->event_action;
target->event_action = teap;
}
Jim_SetEmptyResult(goi->interp); Jim_SetEmptyResult(goi->interp);
} else { } else {
/* get */ /* get */