summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2016-08-13 15:36:46 +0200
committerSébastien Helleu <flashcode@flashtux.org>2016-08-13 15:36:46 +0200
commit4c25604decb54d7b3285f0b97c6d86523af1c585 (patch)
tree8199095f00a83d15de92df82415243dcb4c02712 /src
parent6c6cc73da2e7c0655ae3718b6cb4f7625876f81c (diff)
downloadweechat-4c25604decb54d7b3285f0b97c6d86523af1c585.zip
xfer: fix NULL pointer derefence in case of memory error in xfer_set_{local|remote}_address()
Diffstat (limited to 'src')
-rw-r--r--src/plugins/xfer/xfer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index cef7a23e2..2032a29f6 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -851,7 +851,8 @@ xfer_set_remote_address (struct t_xfer *xfer, const struct sockaddr *address,
free (xfer->remote_address);
xfer->remote_address = malloc (length);
xfer->remote_address_length = length;
- memcpy (xfer->remote_address, address, length);
+ if (xfer->remote_address)
+ memcpy (xfer->remote_address, address, length);
if (xfer->remote_address_str)
free (xfer->remote_address_str);
@@ -869,7 +870,8 @@ xfer_set_local_address (struct t_xfer *xfer, const struct sockaddr *address,
free (xfer->local_address);
xfer->local_address = malloc (length);
xfer->local_address_length = length;
- memcpy (xfer->local_address, address, length);
+ if (xfer->local_address)
+ memcpy (xfer->local_address, address, length);
if (xfer->local_address_str)
free (xfer->local_address_str);