From: Pavel Borzenkov <pavel.borzenkov@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-devel] [PATCH] qed: don't pass NULL to memcpy
Date: Tue, 18 Oct 2011 21:17:35 +0400 [thread overview]
Message-ID: <1318958255-14008-1-git-send-email-pavel.borzenkov@gmail.com> (raw)
Spotted by Clang Analyzer
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
---
block/qed.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index c3e45af..e6720db 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1424,8 +1424,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);
--
1.7.0.4
next reply other threads:[~2011-10-18 17:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 17:17 Pavel Borzenkov [this message]
2011-10-20 17:23 ` [Qemu-devel] [Qemu-trivial] [PATCH] qed: don't pass NULL to memcpy Stefan Hajnoczi
2011-10-21 6:35 ` Paolo Bonzini
2011-10-21 8:31 ` Markus Armbruster
2011-10-21 9:06 ` Pavel Borzenkov
2011-10-21 9:08 ` Pavel Borzenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318958255-14008-1-git-send-email-pavel.borzenkov@gmail.com \
--to=pavel.borzenkov@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).