[vlc-commits] src/darwin: fix crash while accessing http content while no proxy is set

Felix Paul Kühne git at videolan.org
Mon Apr 15 12:59:50 CEST 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Apr 15 12:59:39 2013 +0200| [07bcca1d5c78ad9cf0cbbefece8cccf537680fe6] | committer: Felix Paul Kühne

src/darwin: fix crash while accessing http content while no proxy is set

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07bcca1d5c78ad9cf0cbbefece8cccf537680fe6
---

 src/darwin/netconf.c |   66 ++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/src/darwin/netconf.c b/src/darwin/netconf.c
index 7f38825..45abf9b 100644
--- a/src/darwin/netconf.c
+++ b/src/darwin/netconf.c
@@ -46,43 +46,45 @@ char *vlc_getProxyUrl(const char *url)
         CFNumberRef cfn_httpProxyOn =
             (CFNumberRef)CFDictionaryGetValue(proxies,
                                               kSCPropNetProxiesHTTPEnable);
-        int i_httpProxyOn;
-        CFNumberGetValue(cfn_httpProxyOn, kCFNumberIntType, &i_httpProxyOn);
-        CFRelease(cfn_httpProxyOn);
+        if (cfn_httpProxyOn) {
+            int i_httpProxyOn;
+            CFNumberGetValue(cfn_httpProxyOn, kCFNumberIntType, &i_httpProxyOn);
+            CFRelease(cfn_httpProxyOn);
 
-        if (i_httpProxyOn == 1) // http proxy is on
-        {
-            CFStringRef httpProxy =
-                (CFStringRef)CFDictionaryGetValue(proxies,
-                                                  kSCPropNetProxiesHTTPProxy);
+            if (i_httpProxyOn == 1) // http proxy is on
+            {
+                CFStringRef httpProxy =
+                    (CFStringRef)CFDictionaryGetValue(proxies,
+                                                      kSCPropNetProxiesHTTPProxy);
 
-            if (httpProxy) {
-                CFNumberRef cfn_httpProxyPort =
-                    (CFNumberRef)CFDictionaryGetValue(proxies,
-                                                    kSCPropNetProxiesHTTPPort);
-                int i_httpProxyPort;
-                CFNumberGetValue(cfn_httpProxyPort,
-                                 kCFNumberIntType,
-                                 &i_httpProxyPort);
-                CFRelease(cfn_httpProxyPort);
+                if (httpProxy) {
+                    CFNumberRef cfn_httpProxyPort =
+                        (CFNumberRef)CFDictionaryGetValue(proxies,
+                                                        kSCPropNetProxiesHTTPPort);
+                    int i_httpProxyPort;
+                    CFNumberGetValue(cfn_httpProxyPort,
+                                     kCFNumberIntType,
+                                     &i_httpProxyPort);
+                    CFRelease(cfn_httpProxyPort);
 
-                CFMutableStringRef outputURL =
-                    CFStringCreateMutableCopy(kCFAllocatorDefault,
-                                              0,
-                                              httpProxy);
-                if (i_httpProxyPort > 0)
-                    CFStringAppendFormat(outputURL,
-                                         NULL,
-                                         CFSTR(":%i"),
-                                         i_httpProxyPort);
+                    CFMutableStringRef outputURL =
+                        CFStringCreateMutableCopy(kCFAllocatorDefault,
+                                                  0,
+                                                  httpProxy);
+                    if (i_httpProxyPort > 0)
+                        CFStringAppendFormat(outputURL,
+                                             NULL,
+                                             CFSTR(":%i"),
+                                             i_httpProxyPort);
 
-                CFStringGetCString(outputURL,
-                                   proxy_url,
-                                   sizeof(proxy_url),
-                                   kCFStringEncodingASCII);
-                CFRelease(outputURL);
+                    CFStringGetCString(outputURL,
+                                       proxy_url,
+                                       sizeof(proxy_url),
+                                       kCFStringEncodingASCII);
+                    CFRelease(outputURL);
+                }
+                CFRelease(httpProxy);
             }
-            CFRelease(httpProxy);
         }
         CFRelease(proxies);
     }



More information about the vlc-commits mailing list