Commit:    25f924abf62e70f3474b5885c12a521c68c2066d
Author:    Anatol Belski <a...@php.net>         Mon, 22 Jul 2013 14:50:18 +0200
Parents:   1b4103c09d552c48275564c459122b67d34a9d1a
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=25f924abf62e70f3474b5885c12a521c68c2066d

Log:
fixed possible null deref

Changed paths:
  M  TSRM/tsrm_win32.c


Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 0ced6db..2ec97be 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -625,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);
@@ -639,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;


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to