st/xorg: add sanity checks after malloc
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 21 Sep 2013 16:53:43 +0000 (17:53 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 29 Oct 2013 21:04:37 +0000 (21:04 +0000)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/state_trackers/xorg/xorg_driver.c

index dd243bccbb981de7d7a7c4f48a54324f296bc2d2..097c3549ae88e9601feba7d880b2afd10bb7d033 100644 (file)
@@ -124,6 +124,9 @@ Bool
 xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device)
 {
     char *BusID = malloc(64);
+
+    if (!BusID)
+       return FALSE;
     sprintf(BusID, "pci:%04x:%02x:%02x.%d",
            device->domain, device->bus,
            device->dev, device->func);
@@ -276,6 +279,9 @@ drv_init_drm(ScrnInfoPtr pScrn)
        char *BusID;
 
        BusID = malloc(64);
+       if (!BusID)
+           return FALSE;
+
        sprintf(BusID, "PCI:%d:%d:%d",
                ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
                ms->PciInfo->dev, ms->PciInfo->func