From 14c15c680d50db831f780c97823535f8b2fc14b9 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sat, 24 Mar 2018 17:46:39 +0500 Subject: [PATCH] resolve several possible null pointer dereference issue detected by cppcheck [channels/drive/client/drive_main.c:454] -> [channels/drive/client/drive_main.c:443]: (warning) Either the condition '!irp' is redundant or there is possible null pointer dereference: irp. [client/X11/xf_window.c:582] -> [client/X11/xf_window.c:580]: (warning) Either the condition '!xfc' is redundant or there is possible null pointer dereference: xfc. [winpr/libwinpr/path/test/TestPathShell.c:40] -> [winpr/libwinpr/path/test/TestPathShell.c:43]: (warning) Either the condition '!path' is redundant or there is possible null pointer dereference: path. [winpr/libwinpr/path/test/TestPathShell.c:49] -> [winpr/libwinpr/path/test/TestPathShell.c:52]: (warning) Either the condition '!path' is redundant or there is possible null pointer dereference: path. --- channels/drive/client/drive_main.c | 4 +++- client/X11/xf_window.c | 4 +++- winpr/libwinpr/path/test/TestPathShell.c | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 4eaef9e..c78a8ec 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -440,7 +440,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP* irp) { UINT32 FsInformationClass; - wStream* output = irp->output; + wStream* output = NULL; char* volumeLabel = {"FREERDP"}; char* diskType = {"FAT32"}; WCHAR* outStr = NULL; @@ -454,6 +454,8 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, if (!drive || !irp) return ERROR_INVALID_PARAMETER; + output = irp->output; + if (Stream_GetRemainingLength(irp->input) < 4) return ERROR_INVALID_DATA; diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 406d51c..d28a34d 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -577,11 +577,13 @@ void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window, int width, int height) { XSizeHints* size_hints; - rdpSettings* settings = xfc->context.settings; + rdpSettings* settings = NULL; if (!xfc || !window) return; + settings = xfc->context.settings; + if (!(size_hints = XAllocSizeHints())) return; diff --git a/winpr/libwinpr/path/test/TestPathShell.c b/winpr/libwinpr/path/test/TestPathShell.c index 3c422c4..1e2781d 100644 --- a/winpr/libwinpr/path/test/TestPathShell.c +++ b/winpr/libwinpr/path/test/TestPathShell.c @@ -38,18 +38,26 @@ int TestPathShell(int argc, char* argv[]) char* path = GetKnownPath(id); if (!path) + { rc = -1; - - printf("%s Path: %s\n", name, path); + } + else + { + printf("%s Path: %s\n", name, path); + } free(path); } { char* path = GetKnownSubPath(id, "freerdp"); if (!path) + { rc = -1; - - printf("%s SubPath: %s\n", name, path); + } + else + { + printf("%s SubPath: %s\n", name, path); + } free(path); } } -- 2.7.4