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:
Sam Lantinga committed 2024-07-19 12:22:03 -07:00
1 parent ef884c8aa6
commit bb96320cc4
19 files changed
+66 -71

No files matched your search

+3 -3
View File
@@ -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;