Fix stack address escape in SDL_CameraDevicePermissionOutcome()

If allocation of 'p' fails, 'pending_tail' points to 'pending'.
This commit is contained in:
Mathieu Eyraud
2024-06-04 13:45:00 +02:00
committed by Sam Lantinga
parent c226630086
commit 43c2b42517

View File

@@ -599,12 +599,14 @@ void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool approv
ReleaseCameraDevice(device); ReleaseCameraDevice(device);
SDL_LockRWLockForWriting(camera_driver.device_hash_lock); if (pending.next) { // NULL if event is disabled or disaster struck.
SDL_assert(camera_driver.pending_events_tail != NULL); SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
SDL_assert(camera_driver.pending_events_tail->next == NULL); SDL_assert(camera_driver.pending_events_tail != NULL);
camera_driver.pending_events_tail->next = pending.next; SDL_assert(camera_driver.pending_events_tail->next == NULL);
camera_driver.pending_events_tail = pending_tail; camera_driver.pending_events_tail->next = pending.next;
SDL_UnlockRWLock(camera_driver.device_hash_lock); camera_driver.pending_events_tail = pending_tail;
SDL_UnlockRWLock(camera_driver.device_hash_lock);
}
} }