mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
fixed possible null deref
This commit is contained in:
parent
1b4103c09d
commit
25f924abf6
1 changed files with 5 additions and 3 deletions
|
@ -625,7 +625,7 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||||
shm->info = info_handle;
|
shm->info = info_handle;
|
||||||
shm->descriptor = MapViewOfFileEx(shm->info, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
|
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_perm.key = key;
|
||||||
shm->descriptor->shm_segsz = size;
|
shm->descriptor->shm_segsz = size;
|
||||||
shm->descriptor->shm_ctime = time(NULL);
|
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;
|
shm->descriptor->shm_perm.mode = shm->descriptor->shm_perm.seq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shm->descriptor->shm_perm.key != key || size > shm->descriptor->shm_segsz ) {
|
if (NULL != shm->descriptor && (shm->descriptor->shm_perm.key != key || size > shm->descriptor->shm_segsz)) {
|
||||||
CloseHandle(shm->segment);
|
if (NULL != shm->segment) {
|
||||||
|
CloseHandle(shm->segment);
|
||||||
|
}
|
||||||
UnmapViewOfFile(shm->descriptor);
|
UnmapViewOfFile(shm->descriptor);
|
||||||
CloseHandle(shm->info);
|
CloseHandle(shm->info);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue