Avoid double-free on error in evbuffer_add_file. Found by coverity.

This commit is contained in:
Nick Mathewson 2012-07-26 10:45:10 -04:00
parent 6487f63b79
commit 6a81b1f5a4

View File

@ -3184,7 +3184,8 @@ evbuffer_add_file(struct evbuffer *buf, int fd, ev_off_t offset, ev_off_t length
if (!seg)
return -1;
r = evbuffer_add_file_segment(buf, seg, 0, length);
evbuffer_file_segment_free(seg);
if (r == 0)
evbuffer_file_segment_free(seg);
return r;
}