From 035bcb7fa5b3ac93971a832725c4a4815ba86fd2 Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Thu, 23 Jul 2009 17:45:43 +0000 Subject: Fix a FORWARD_NULL defect in ExtractModuleName reported by Coverity. If 'sep' is still NULL after the for loop, ix must be -1, so ix == 0 cannot be true. Update the comment for ExtractModuleName in the header to match the implementation. I don't see any code that checks whether the path is a full path. R=rvargas BUG=http://crbug.com/17101 TEST=none Review URL: http://codereview.chromium.org/155979 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21404 0039d316-1c4b-4281-b951-d872f2087c98 --- sandbox/src/sandbox_nt_util.cc | 5 ++--- sandbox/src/sandbox_nt_util.h | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'sandbox') diff --git a/sandbox/src/sandbox_nt_util.cc b/sandbox/src/sandbox_nt_util.cc index ae5556e..e8a56a7 100644 --- a/sandbox/src/sandbox_nt_util.cc +++ b/sandbox/src/sandbox_nt_util.cc @@ -301,7 +301,6 @@ UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags) { if (headers->OptionalHeader.SizeOfCode) *flags |= MODULE_HAS_CODE; } - } while (false); } __except(EXCEPTION_EXECUTE_HANDLER) { } @@ -349,7 +348,7 @@ UNICODE_STRING* ExtractModuleName(const UNICODE_STRING* module_path) { int start_pos = module_path->Length / sizeof(wchar_t) - 1; int ix = start_pos; - for(; ix >= 0; --ix) { + for (; ix >= 0; --ix) { if (module_path->Buffer[ix] == L'\\') { sep = &module_path->Buffer[ix]; break; @@ -361,7 +360,7 @@ UNICODE_STRING* ExtractModuleName(const UNICODE_STRING* module_path) { return NULL; // No path separator found. Use the entire name. - if ((ix == 0) && !sep) { + if (!sep) { sep = &module_path->Buffer[-1]; } diff --git a/sandbox/src/sandbox_nt_util.h b/sandbox/src/sandbox_nt_util.h index f979a0d..87d2409 100644 --- a/sandbox/src/sandbox_nt_util.h +++ b/sandbox/src/sandbox_nt_util.h @@ -118,9 +118,9 @@ UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags); UNICODE_STRING* GetBackingFilePath(PVOID address); // Returns the last component of a path that contains the module name. -// It will return NULL if the path is not a full path or if the path ends -// with the path separator. The returned buffer must be freed with a placement -// delete (see GetImageNameFromModule example). +// It will return NULL if the path ends with the path separator. The returned +// buffer must be freed with a placement delete (see GetImageNameFromModule +// example). UNICODE_STRING* ExtractModuleName(const UNICODE_STRING* module_path); // Returns true if the parameters correspond to a dll mapped as code. -- cgit v1.1