diff --git a/nemu/src/monitor/sdb/watchpoint.c b/nemu/src/monitor/sdb/watchpoint.c index d283a7d..103809d 100644 --- a/nemu/src/monitor/sdb/watchpoint.c +++ b/nemu/src/monitor/sdb/watchpoint.c @@ -62,7 +62,7 @@ bool wp_check_hit(void) { } static WP* del_wp(WP** head, WP* pos) { - for (WP** i = head; (*i) != NULL && (*i)->next != NULL; i = (WP**)*i) { + for (WP** i = head; (*i) != NULL; i = (WP**)*i) { if ((**i).NO == pos->NO) { WP* res = *i; *i = (*i)->next; @@ -112,6 +112,7 @@ void free_wp(WP *_wp) { WP* wp = del_wp(&head, _wp); if (wp == NULL) { printf("free_wp: no such watchpoint\n"); + return; } wp->next = free_; free_ = wp;