mirror of https://gitee.com/openkylin/qemu.git
usb/hid: avoid dynamic stack allocation
Use autofree heap allocation instead. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210503132915.2335822-2-kraxel@redhat.com>
This commit is contained in:
parent
9c3c834bdd
commit
3f67e2e7f1
|
@ -656,7 +656,7 @@ static void usb_hid_handle_data(USBDevice *dev, USBPacket *p)
|
|||
{
|
||||
USBHIDState *us = USB_HID(dev);
|
||||
HIDState *hs = &us->hid;
|
||||
uint8_t buf[p->iov.size];
|
||||
g_autofree uint8_t *buf = g_malloc(p->iov.size);
|
||||
int len = 0;
|
||||
|
||||
switch (p->pid) {
|
||||
|
|
|
@ -301,7 +301,7 @@ static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,
|
|||
static void usb_wacom_handle_data(USBDevice *dev, USBPacket *p)
|
||||
{
|
||||
USBWacomState *s = (USBWacomState *) dev;
|
||||
uint8_t buf[p->iov.size];
|
||||
g_autofree uint8_t *buf = g_malloc(p->iov.size);
|
||||
int len = 0;
|
||||
|
||||
switch (p->pid) {
|
||||
|
|
Loading…
Reference in New Issue