aboutsummaryrefslogtreecommitdiff
path: root/block/qed.c
diff options
context:
space:
mode:
authorPavel Borzenkov <pavel.borzenkov@gmail.com>2011-10-18 21:17:35 +0400
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-10-26 13:36:35 +0100
commitfeba23b14340965b9dad9251ec9a7a47313fbf69 (patch)
tree38806b29e669df865755b76ac8a069bf43b01b03 /block/qed.c
parent8379e46d1fd681b8aa4714382e2cdab05e5d0575 (diff)
downloadqemu-feba23b14340965b9dad9251ec9a7a47313fbf69.zip
qemu-feba23b14340965b9dad9251ec9a7a47313fbf69.tar.gz
qemu-feba23b14340965b9dad9251ec9a7a47313fbf69.tar.bz2
qed: don't pass NULL to memcpy
Spotted by Clang Analyzer [Note this memcpy call has always been safe because the length will be 0 when the pointer is NULL] Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r--block/qed.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/block/qed.c b/block/qed.c
index e87dc4d..7fab155 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1425,8 +1425,10 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs,
memcpy(buffer, &le_header, sizeof(le_header));
buffer_len = sizeof(le_header);
- memcpy(buffer + buffer_len, backing_file, backing_file_len);
- buffer_len += backing_file_len;
+ if (backing_file) {
+ memcpy(buffer + buffer_len, backing_file, backing_file_len);
+ buffer_len += backing_file_len;
+ }
/* Write new header */
ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len);