From 85a43cfa66b9e81336b31f3d622e7dc401092138 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 18 Jun 2014 13:06:05 +0900 Subject: [PATCH] examples: Check return value of evbuffer_drain --- examples/libevent-client.c | 6 +++++- examples/libevent-server.c | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/libevent-client.c b/examples/libevent-client.c index a1994494..598c67e7 100644 --- a/examples/libevent-client.c +++ b/examples/libevent-client.c @@ -425,7 +425,11 @@ static void readcb(struct bufferevent *bev, void *ptr) delete_http2_session_data(session_data); return; } - evbuffer_drain(input, readlen); + if(evbuffer_drain(input, readlen) != 0) { + warnx("Fatal error: evbuffer_drain failed"); + delete_http2_session_data(session_data); + return; + } if(session_send(session_data) != 0) { delete_http2_session_data(session_data); return; diff --git a/examples/libevent-server.c b/examples/libevent-server.c index fce3c409..e5a416c9 100644 --- a/examples/libevent-server.c +++ b/examples/libevent-server.c @@ -250,7 +250,10 @@ static int session_recv(http2_session_data *session_data) warnx("Fatal error: %s", nghttp2_strerror((int)readlen)); return -1; } - evbuffer_drain(input, readlen); + if(evbuffer_drain(input, readlen) != 0) { + warnx("Fatal error: evbuffer_drain failed"); + return -1; + } if(session_send(session_data) != 0) { return -1; }