diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-11-27 03:19:59 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-11-27 03:19:59 +0000 |
commit | cbee428be1dcb77d1323599abcd2bf99cdafaf71 (patch) | |
tree | e417dab3a5cb52de911468aa3f38dc7074e915d7 /usr.sbin/relayd | |
parent | 56307fe145f235646c7bac462a97cffbb2d9b917 (diff) |
Simplify relay_close_http(), make relay_httpdesc_free() accept and ignore
a NULL pointer argument (like free()). Also switch a !size to size == 0.
OK benno@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/relay_http.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index 3b6f8e84e37..847737de47b 100644 --- a/usr.sbin/relayd/relay_http.c +++ b/usr.sbin/relayd/relay_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_http.c,v 1.68 2017/11/15 19:03:26 benno Exp $ */ +/* $OpenBSD: relay_http.c,v 1.69 2017/11/27 03:19:58 claudio Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -126,6 +126,9 @@ relay_httpdesc_init(struct ctl_relay_event *cre) void relay_httpdesc_free(struct http_descriptor *desc) { + if (desc == NULL) + return; + free(desc->http_path); desc->http_path = NULL; free(desc->http_query); @@ -162,7 +165,7 @@ relay_read_http(struct bufferevent *bev, void *arg) size = EVBUFFER_LENGTH(src); DPRINTF("%s: session %d: size %lu, to read %lld", __func__, con->se_id, size, cre->toread); - if (!size) { + if (size == 0) { if (cre->dir == RELAY_DIR_RESPONSE) return; cre->toread = TOREAD_HTTP_HEADER; @@ -1063,17 +1066,10 @@ relay_abort_http(struct rsession *con, u_int code, const char *msg, void relay_close_http(struct rsession *con) { - struct http_descriptor *desc[2] = { - con->se_in.desc, con->se_out.desc - }; - int i; - - for (i = 0; i < 2; i++) { - if (desc[i] == NULL) - continue; - relay_httpdesc_free(desc[i]); - free(desc[i]); - } + relay_httpdesc_free(con->se_in.desc); + free(con->se_in.desc); + relay_httpdesc_free(con->se_out.desc); + free(con->se_out.desc); } char * |