mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-01 23:48:29 +00:00
Make sure we always copy the data returned using SDL_GetStringRule
This prevents race conditions where calling an API from one thread returns the data and it's freed by updates on another thread
This commit is contained in:
@@ -286,7 +286,7 @@ static void DestroyPhysicalCamera(SDL_Camera *device)
|
||||
camera_driver.impl.FreeDeviceHandle(device);
|
||||
SDL_DestroyMutex(device->lock);
|
||||
SDL_free(device->all_specs);
|
||||
SDL_FreeLater(device->name); // this is returned in SDL_GetCameraName.
|
||||
SDL_free(device->name);
|
||||
SDL_free(device);
|
||||
}
|
||||
}
|
||||
@@ -674,10 +674,10 @@ int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
|
||||
|
||||
const char *SDL_GetCameraName(SDL_CameraID instance_id)
|
||||
{
|
||||
char *retval = NULL;
|
||||
const char *retval = NULL;
|
||||
SDL_Camera *device = ObtainPhysicalCamera(instance_id);
|
||||
if (device) {
|
||||
retval = device->name;
|
||||
retval = SDL_CreateTemporaryString(device->name);
|
||||
ReleaseCamera(device);
|
||||
}
|
||||
return retval;
|
||||
|
Reference in New Issue
Block a user