This commit fixes following issue reported by svace:
"Variable 'cinfo.prstatus_fd', which may receive negative value at
crash-manager.c:588 by calling function 'set_crash_info' at
crash-manager.c:1267, is used at crash-manager.c:1332 by calling
function 'close'."
Change-Id: Ie625bc8ac5eb16a84bb7b139b569c6189e1a5e25
int main(int argc, char *argv[])
{
- struct crash_info cinfo = {0};
+ struct crash_info cinfo = {.prstatus_fd = -1};
/* Execute dump_systemstate in parallel */
static int dump_state_pid;
launch_crash_popup(&cinfo);
exit:
- close(cinfo.prstatus_fd);
+ if (cinfo.prstatus_fd >= 0)
+ close(cinfo.prstatus_fd);
free(crash_temp_path);
free(crash_root_path);
free(crash_crash_path);