[PATCH xserver 3/3] config: Ensure that stolen option list elements are released.

Rami Ylimäki rami.ylimaki at vincit.fi
Fri Mar 4 07:55:33 PST 2011


NewInputDeviceRequest steals the contents of option list elements but
doesn't use the elements themselves for anything. Therefore the list
elements need to be released always.

Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
---
 config/hal.c  |    6 +++---
 config/udev.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/config/hal.c b/config/hal.c
index 6e2850c..5ade2f6 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -393,10 +393,10 @@ unwind:
     free(driver);
     free(name);
     free(config_info);
-    while (!dev && (tmpo = options)) {
+    while ((tmpo = options)) {
         options = tmpo->next;
-        free(tmpo->key);
-        free(tmpo->value);
+        free(tmpo->key);        /* NULL if dev != NULL */
+        free(tmpo->value);      /* NULL if dev != NULL */
         free(tmpo);
     }
 
diff --git a/config/udev.c b/config/udev.c
index cb38276..a2f5710 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -191,10 +191,10 @@ device_added(struct udev_device *udev_device)
 
  unwind:
     free(config_info);
-    while (!dev && (tmpo = options)) {
+    while ((tmpo = options)) {
         options = tmpo->next;
-        free(tmpo->key);
-        free(tmpo->value);
+        free(tmpo->key);        /* NULL if dev != NULL */
+        free(tmpo->value);      /* NULL if dev != NULL */
         free(tmpo);
     }
 
-- 
1.6.3.3



More information about the xorg-devel mailing list