]> granicus.if.org Git - php/commitdiff
fixed possible null deref
authorAnatol Belski <ab@php.net>
Mon, 22 Jul 2013 12:50:18 +0000 (14:50 +0200)
committerAnatol Belski <ab@php.net>
Mon, 22 Jul 2013 12:50:18 +0000 (14:50 +0200)
TSRM/tsrm_win32.c

index 0ced6db451bfe1227f131700ce46d0bbb9e0510d..2ec97be0116bcd823a387ec94747302f7643ca67 100644 (file)
@@ -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;