Avoid more crashes/bad calls in unit tests; found by coverity

This commit is contained in:
Nick Mathewson 2012-07-26 10:04:43 -04:00
parent f021c3d762
commit 3cde5bf57a
2 changed files with 12 additions and 5 deletions

View File

@ -2258,7 +2258,8 @@ end:
event_free(ev1);
if (ev2)
event_free(ev2);
close(dfd);
if (dfd >= 0)
close(dfd);
}
#endif

View File

@ -243,6 +243,8 @@ test_bufferevent_watermarks_impl(int use_pair)
bev1 = bufferevent_new(pair[0], NULL, wm_writecb, wm_errorcb, NULL);
bev2 = bufferevent_new(pair[1], wm_readcb, NULL, wm_errorcb, NULL);
}
tt_assert(bev1);
tt_assert(bev2);
bufferevent_disable(bev1, EV_READ);
bufferevent_enable(bev2, EV_READ);
@ -267,8 +269,10 @@ test_bufferevent_watermarks_impl(int use_pair)
tt_assert(!event_pending(&bev2->ev_write, EV_WRITE, NULL));
end:
bufferevent_free(bev1);
bufferevent_free(bev2);
if (bev1)
bufferevent_free(bev1);
if (bev2)
bufferevent_free(bev2);
}
static void
@ -377,8 +381,10 @@ test_bufferevent_filters_impl(int use_pair)
test_ok = 0;
end:
bufferevent_free(bev1);
bufferevent_free(bev2);
if (bev1)
bufferevent_free(bev1);
if (bev2)
bufferevent_free(bev2);
}