This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/xawtv3.git tree:

Subject: Don't call strdup on NULL
Author:  Hans de Goede <[email protected]>
Date:    Thu Jun 21 14:42:42 2012 +0200

This fixes radio / xawtv crashing when no associated alsa capture device can
be found.

Signed-off-by: Hans de Goede <[email protected]>

 console/radio.c |   13 +++++++------
 x11/xt.c        |   11 +++++++----
 2 files changed, 14 insertions(+), 10 deletions(-)

---

http://git.linuxtv.org/xawtv3.git?a=commitdiff;h=2550984180f940c4379651245db468602cb38354

diff --git a/console/radio.c b/console/radio.c
index 4f355b6..b89c217 100644
--- a/console/radio.c
+++ b/console/radio.c
@@ -789,20 +789,21 @@ int main(int argc, char *argv[])
 #if defined(HAVE_ALSA)
     if (alsa_loopback && alsa_capture == NULL) {
        void *md = discover_media_devices();
-       char *p = strrchr(device, '/');
+       const char *p = strrchr(device, '/');
        if (p)
            p++;
        else
            p = device;
-       alsa_capture = strdup(get_associated_device(md, NULL,
-                                                   MEDIA_SND_CAP, p,
-                                                   MEDIA_V4L_RADIO));
-       if (alsa_capture == NULL)
+
+       p = get_associated_device(md, NULL, MEDIA_SND_CAP, p, MEDIA_V4L_RADIO);
+       if (p)
+           alsa_capture = strdup(p);
+       else
            alsa_loopback = 0;
 
        free_media_devices(md);
     }
-    
+
     if (alsa_playback == NULL)
        alsa_playback = "default";
 
diff --git a/x11/xt.c b/x11/xt.c
index 8edf577..2065ff4 100644
--- a/x11/xt.c
+++ b/x11/xt.c
@@ -1470,7 +1470,7 @@ grabber_init()
     if (args.alsa) {
        /* Start audio capture thread */
        void *md = discover_media_devices();
-       char *p = strrchr(args.device, '/');
+       const char *p = strrchr(args.device, '/');
        if (p)
            p++;
        else
@@ -1478,9 +1478,12 @@ grabber_init()
 
        if (args.alsa_cap)
            alsa_cap = args.alsa_cap;
-       else
-           alsa_cap = strdup(get_associated_device(md, NULL, MEDIA_SND_CAP,
-                                                   p, MEDIA_V4L_VIDEO));
+       else {
+           p = get_associated_device(md, NULL, MEDIA_SND_CAP,
+                                     p, MEDIA_V4L_VIDEO);
+           if (p)
+               alsa_cap = strdup(p);
+       }
 
        if (args.alsa_pb)
            alsa_out = args.alsa_pb;

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to