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

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