diff options
author | Kitae Kim <kt920.kim@samsung.com> | 2014-03-28 10:27:53 +0900 |
---|---|---|
committer | Kitae Kim <kt920.kim@samsung.com> | 2014-03-28 14:54:36 +0900 |
commit | d96ec7e30fffe389aadd6872e3a9ed46faeec7af (patch) | |
tree | ff0a26514f15f6d0d8210ffb12c7ee1d5ff1dbb4 | |
parent | a9633512c38e66ff30b15d0a3037519c298bff7b (diff) | |
download | qemu-d96ec7e30fffe389aadd6872e3a9ed46faeec7af.tar.gz qemu-d96ec7e30fffe389aadd6872e3a9ed46faeec7af.tar.bz2 qemu-d96ec7e30fffe389aadd6872e3a9ed46faeec7af.zip |
qemu: fix dereference before null check
Change-Id: I750bf92f87ed2103f696ba3f8812075744941722
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
-rw-r--r-- | blockdev.c | 5 | ||||
-rw-r--r-- | tizen/src/maru_err_table.c | 13 |
2 files changed, 10 insertions, 8 deletions
diff --git a/blockdev.c b/blockdev.c index 9a4a8fbde2..84a48a0ebf 100644 --- a/blockdev.c +++ b/blockdev.c @@ -522,10 +522,11 @@ static DriveInfo *blockdev_init(QDict *bs_opts, if (ret < 0) { #ifdef CONFIG_MARU const char _msg[] = "Failed to load disk file from the following path. Check if the file is corrupted or missing.\n\n"; - char* err_msg = NULL; + char* err_msg = NULL; + err_msg = maru_convert_path((char*)_msg, file); - start_simple_client(err_msg); if (err_msg) { + start_simple_client(err_msg); g_free(err_msg); } #endif diff --git a/tizen/src/maru_err_table.c b/tizen/src/maru_err_table.c index 508a70ae31..29f55d699d 100644 --- a/tizen/src/maru_err_table.c +++ b/tizen/src/maru_err_table.c @@ -166,6 +166,11 @@ char *maru_convert_path(char *msg, const char *path) total_len += (path_len + msg_len); err_msg = g_malloc0(total_len * sizeof(char)); + if (!err_msg) { + fprintf(stderr, "failed to allocate a buffer for an error massage\n"); + g_free(current_path); + return NULL; + } if (msg) { snprintf(err_msg, msg_len, "%s", msg); @@ -188,9 +193,7 @@ char *maru_convert_path(char *msg, const char *path) if (!dos_err_msg) { fprintf(stderr, "failed to duplicate an error message from %p\n", err_msg); - if (current_path) { - g_free(current_path); - } + g_free(current_path); g_free(err_msg); return NULL; } @@ -204,9 +207,7 @@ char *maru_convert_path(char *msg, const char *path) g_free(dos_err_msg); } #endif - if (current_path) { - g_free(current_path); - } + g_free(current_path); return err_msg; } |