Blame SOURCES/0003-Fix-handling-of-realloc-failure.patch

bff68f
From 3370b6b6a41a27123a45b95ba4820395127c84e7 Mon Sep 17 00:00:00 2001
bff68f
From: Peter Hutterer <peter.hutterer@who-t.net>
bff68f
Date: Mon, 8 Oct 2018 13:05:09 +1000
bff68f
Subject: [PATCH xf86-video-v4l 3/4] Fix handling of realloc failure
bff68f
bff68f
Coverity complaint and whatnot
bff68f
bff68f
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
bff68f
Reviewed-by: Dave Airlie <airlied@redhat.com>
bff68f
---
bff68f
 src/v4l.c | 7 ++++++-
bff68f
 1 file changed, 6 insertions(+), 1 deletion(-)
bff68f
bff68f
diff --git a/src/v4l.c b/src/v4l.c
bff68f
index 583c7b8..8c2408c 100644
bff68f
--- a/src/v4l.c
bff68f
+++ b/src/v4l.c
bff68f
@@ -1120,6 +1120,7 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
bff68f
     XF86VideoAdaptorPtr *VAR = NULL;
bff68f
     char dev[18];
bff68f
     int  fd,i,j,d;
bff68f
+    void *tmp;
bff68f
 
bff68f
     for (i = 0, d = 0; d < MAX_V4L_DEVICES; d++) {
bff68f
         sprintf(dev, "/dev/video%d", d);
bff68f
@@ -1164,7 +1165,11 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
bff68f
             return FALSE;
bff68f
 
bff68f
         /* alloc VideoAdaptorRec */
bff68f
-        VAR = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
bff68f
+        tmp = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
bff68f
+        if (!tmp)
bff68f
+            return FALSE;
bff68f
+        VAR = tmp;
bff68f
+
bff68f
         VAR[i] = malloc(sizeof(XF86VideoAdaptorRec));
bff68f
         if (!VAR[i])
bff68f
             return FALSE;
bff68f
-- 
bff68f
2.17.1
bff68f