From fb348d22afc85a2dfba80c3059391e8bc276e9ca Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 2 Jul 2012 19:48:33 +0000 Subject: [PATCH] * external.cc (fillout_pinfo): Return NULL rather than 0. (exit_process): Guard against NULL pointer dereference found by Clang. --- winsup/cygwin/ChangeLog | 9 +++++++-- winsup/cygwin/external.cc | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5ff6fab88..611ba0dc4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,12 +1,17 @@ +2012-07-02 Christopher Faylor + + * external.cc (fillout_pinfo): Return NULL rather than 0. + (exit_process): Guard against NULL pointer dereference found by Clang. + 2012-07-02 Christopher Faylor * mount.cc (mount_info::conv_to_win32_path): Eliminate unneeded - assignment found by CLANG. + assignment found by Clang. 2012-07-02 Christopher Faylor * path.cc (symlink_info::check): Remove unneeded/unused variable found - by CLANG. + by Clang. 2012-07-02 Corinna Vinschen diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index cd86966b8..22636aa53 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -108,7 +108,7 @@ fillout_pinfo (pid_t pid, int winpid) { i = 0; pids.reset (); - return 0; + return NULL; } return &ep; } @@ -186,10 +186,12 @@ static void exit_process (UINT status, bool useTerminateProcess) { pid_t pid = getpid (); - external_pinfo * ep = fillout_pinfo (pid, 1); + external_pinfo *ep = fillout_pinfo (pid, 1); DWORD dwpid = ep ? ep->dwProcessId : pid; pinfo p (pid, PID_MAP_RW); - if ((dwpid == GetCurrentProcessId()) && (p->pid == ep->pid)) + if (ep) + pid = ep->pid; + if ((dwpid == GetCurrentProcessId()) && (p->pid == pid)) p.set_exit_code ((DWORD)status); if (useTerminateProcess) TerminateProcess (GetCurrentProcess(), status);