From 2963b4362c2afb41e2cb3396dbe9921082abc3c0 Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 6 Feb 2018 05:08:27 +0000 Subject: [PATCH] move malloc check up so that it actually works. OK benno --- usr.sbin/acme-client/netproc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.sbin/acme-client/netproc.c b/usr.sbin/acme-client/netproc.c index 1c2f7f125c9..26033a3fc3c 100644 --- a/usr.sbin/acme-client/netproc.c +++ b/usr.sbin/acme-client/netproc.c @@ -1,4 +1,4 @@ -/* $Id: netproc.c,v 1.14 2017/11/27 01:58:52 florian Exp $ */ +/* $Id: netproc.c,v 1.15 2018/02/06 05:08:27 florian Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -209,12 +209,12 @@ nreq(struct conn *c, const char *addr) free(c->buf.buf); c->buf.sz = g->bodypartsz; c->buf.buf = malloc(c->buf.sz); - memcpy(c->buf.buf, g->bodypart, c->buf.sz); - http_get_free(g); if (c->buf.buf == NULL) { warn("malloc"); - return -1; - } + code = -1; + } else + memcpy(c->buf.buf, g->bodypart, c->buf.sz); + http_get_free(g); return code; } @@ -310,12 +310,12 @@ sreq(struct conn *c, const char *addr, const char *req) free(c->buf.buf); c->buf.sz = g->bodypartsz; c->buf.buf = malloc(c->buf.sz); - memcpy(c->buf.buf, g->bodypart, c->buf.sz); - http_get_free(g); if (c->buf.buf == NULL) { warn("malloc"); - return -1; - } + code = -1; + } else + memcpy(c->buf.buf, g->bodypart, c->buf.sz); + http_get_free(g); return code; } -- 2.20.1