From 464bd414a14d38c3fbb3658d80bf1df37b4cd623 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Thu, 2 Apr 2009 13:17:16 +0200 Subject: [PATCH] Properly guard bytes_written against NULL ws_copyfile() can be called with bytes_copied == NULL but did not check for this condition before using bytes_copied after an IO error, leading to a segfault. --- src/webserver.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/webserver.c b/src/webserver.c index 31ccd86e..ee2387c5 100644 --- a/src/webserver.c +++ b/src/webserver.c @@ -2044,7 +2044,10 @@ int ws_copyfile(WS_CONNINFO *pwsc, IOHANDLE hfile, uint64_t *bytes_copied) { bytes_written = bytes_read; if(!io_write(pwsc->hclient,buf,&bytes_written)) { ws_dprintf(L_WS_LOG,"Write error: %s\n",io_errstr(pwsc->hclient)); - *bytes_copied = total_bytes; + + if (bytes_copied) + *bytes_copied = total_bytes; + return FALSE; }