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.
This commit is contained in:
Julien BLACHE 2009-04-02 13:17:16 +02:00
parent 46acba0edb
commit 464bd414a1

View File

@ -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;
}