[PATCH] winedump: Fix potential null-pointer dereference (cppcheck)
Fabian Maurer
dark.shadow4 at web.de
Tue Oct 3 10:28:08 CDT 2017
ret is only checked for null before the return, but not in the printf.
This patch fixes that.
Found by cppcheck.
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
tools/winedump/pdb.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c
index 6a6a9b4682..f67e1f6ce3 100644
--- a/tools/winedump/pdb.c
+++ b/tools/winedump/pdb.c
@@ -215,8 +215,16 @@ static void *read_string_table(struct pdb_reader* reader)
stream_idx = get_stream_by_name(reader, "/names");
if (stream_idx == -1) return NULL;
ret = reader->read_file(reader, stream_idx);
- if (ret && *(const DWORD*)ret == 0xeffeeffe) return ret;
- printf("wrong header %x expecting 0xeffeeffe\n", *(const DWORD*)ret);
+ if (ret)
+ {
+ if(*(const DWORD*)ret == 0xeffeeffe)
+ return ret;
+ else
+ printf("wrong header %x expecting 0xeffeeffe\n", *(const DWORD*)ret);
+ }
+ else
+ printf("failed to read file\n");
+
free( ret );
return NULL;
}
--
2.14.2
More information about the wine-patches
mailing list