--- embedaddon/php/TSRM/tsrm_win32.c 2012/05/29 12:34:34 1.1.1.2 +++ embedaddon/php/TSRM/tsrm_win32.c 2013/10/14 08:02:46 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tsrm_win32.c,v 1.1.1.2 2012/05/29 12:34:34 misho Exp $ */ +/* $Id: tsrm_win32.c,v 1.1.1.4 2013/10/14 08:02:46 misho Exp $ */ #include #include @@ -193,7 +193,7 @@ Finished: TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC) { time_t t; - HANDLE thread_token; + HANDLE thread_token = NULL; PSID token_sid; SECURITY_INFORMATION sec_info = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION; GENERIC_MAPPING gen_map = { FILE_GENERIC_READ, FILE_GENERIC_WRITE, FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS }; @@ -363,6 +363,9 @@ Finished_Impersonate: } Finished: + if(thread_token != NULL) { + CloseHandle(thread_token); + } if(real_path != NULL) { free(real_path); real_path = NULL; @@ -622,7 +625,7 @@ TSRM_API int shmget(int key, int size, int flags) shm->info = info_handle; shm->descriptor = MapViewOfFileEx(shm->info, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL); - if (created) { + if (NULL != shm->descriptor && created) { shm->descriptor->shm_perm.key = key; shm->descriptor->shm_segsz = size; shm->descriptor->shm_ctime = time(NULL); @@ -636,8 +639,10 @@ TSRM_API int shmget(int key, int size, int flags) shm->descriptor->shm_perm.mode = shm->descriptor->shm_perm.seq = 0; } - if (shm->descriptor->shm_perm.key != key || size > shm->descriptor->shm_segsz ) { - CloseHandle(shm->segment); + if (NULL != shm->descriptor && (shm->descriptor->shm_perm.key != key || size > shm->descriptor->shm_segsz)) { + if (NULL != shm->segment) { + CloseHandle(shm->segment); + } UnmapViewOfFile(shm->descriptor); CloseHandle(shm->info); return -1;