mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-03-02 15:31:52 +00:00
Fix size_t to int truncation in fluid_wasapi_finddev_callback()
This commit is contained in:
parent
f013e82d58
commit
d554067fc5
1 changed files with 10 additions and 3 deletions
|
@ -803,6 +803,7 @@ static void fluid_wasapi_finddev_callback(IMMDevice *dev, void *data)
|
||||||
{
|
{
|
||||||
fluid_wasapi_finddev_data_t *d = (fluid_wasapi_finddev_data_t *)data;
|
fluid_wasapi_finddev_data_t *d = (fluid_wasapi_finddev_data_t *)data;
|
||||||
int nsz;
|
int nsz;
|
||||||
|
size_t id_len;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
wchar_t *id = NULL;
|
wchar_t *id = NULL;
|
||||||
IPropertyStore *prop = NULL;
|
IPropertyStore *prop = NULL;
|
||||||
|
@ -841,9 +842,15 @@ static void fluid_wasapi_finddev_callback(IMMDevice *dev, void *data)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsz = wcslen(id);
|
id_len = wcslen(id);
|
||||||
d->id = FLUID_ARRAY(wchar_t, nsz + 1);
|
if(id_len >= UINT_MAX / sizeof(wchar_t))
|
||||||
FLUID_MEMCPY(d->id, id, sizeof(wchar_t) * (nsz + 1));
|
{
|
||||||
|
FLUID_LOG(FLUID_ERR, "wasapi: the returned device identifier was way too long");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
id_len++;
|
||||||
|
d->id = FLUID_ARRAY(wchar_t, id_len);
|
||||||
|
FLUID_MEMCPY(d->id, id, sizeof(wchar_t) * id_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
Loading…
Reference in a new issue