summaryrefslogtreecommitdiff
blob: b0df809c9398932db35e744e1e1b7913341579f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From cf9903466c1a2d18a701f3b5e8c7e03483e1244d Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Mon, 14 Oct 2019 16:39:28 +0200
Subject: [PATCH] udev-configure-printer: Add checks for NULL

---
 udev/udev-configure-printer.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/udev/udev-configure-printer.c b/udev/udev-configure-printer.c
index 83092fc21..d753bbeaf 100644
--- a/udev/udev-configure-printer.c
+++ b/udev/udev-configure-printer.c
@@ -1411,7 +1411,7 @@ for_each_matching_queue (struct device_uris *device_uris,
       const char *printer_state_message = NULL;
       int state = 0;
       size_t i, l;
-      char *this_device_uri_n, *device_uri_n;
+      char *this_device_uri_n = NULL, *device_uri_n = NULL;
       const char *ps1, *ps2, *pi1, *pi2;
 
       while (attr && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
@@ -1448,6 +1448,8 @@ for_each_matching_queue (struct device_uris *device_uris,
       for (i = 0; i < device_uris->n_uris; i++)
 	{
 	  device_uri_n = normalize_device_uri(device_uris->uri[i]);
+          if (this_device_uri_n == NULL || device_uri_n == NULL)
+            goto skip;
 	  /* As for the same device different URIs can come out when the
 	     device is accessed via the usblp kernel module or via low-
 	     level USB (libusb) we cannot simply compare URIs, must
@@ -1512,8 +1514,12 @@ for_each_matching_queue (struct device_uris *device_uris,
       firstqueue = 0;
 
     skip:
-      free(device_uri_n);
-      free(this_device_uri_n);
+      if (device_uri_n != NULL)
+        free(device_uri_n);
+        device_uri_n = NULL;
+      if (this_device_uri_n != NULL)
+        free(this_device_uri_n);
+        this_device_uri_n = NULL;
       if (!attr)
 	break;
     }