Bug 1310518 - fix crashes when downloading files without referrer/source URL, r=mstange
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 28 Oct 2016 17:38:29 +0100
changeset 320016 2caaf35f549ba8b2931ecbbe0d1f07fddf2cdcd9
parent 320015 54b73853d144d7c097c089f077a181014d2212bd
child 320017 8476b951e74f9e0f4f6e324d2ff8d7ceb79d17f0
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1310518
milestone52.0a1
Bug 1310518 - fix crashes when downloading files without referrer/source URL, r=mstange MozReview-Commit-ID: HnSb0yxlAfs
xpcom/io/CocoaFileUtils.mm
--- a/xpcom/io/CocoaFileUtils.mm
+++ b/xpcom/io/CocoaFileUtils.mm
@@ -234,21 +234,21 @@ void AddQuarantineMetadataToFile(const C
 
   // Add metadata that the OS couldn't infer.
 
   if (!::CFDictionaryGetValue(mutQuarantineProps, kLSQuarantineTypeKey)) {
     CFStringRef type = isFromWeb ? kLSQuarantineTypeWebDownload : kLSQuarantineTypeOtherDownload;
     ::CFDictionarySetValue(mutQuarantineProps, kLSQuarantineTypeKey, type);
   }
 
-  if (!::CFDictionaryGetValue(mutQuarantineProps, kLSQuarantineOriginURLKey)) {
+  if (!::CFDictionaryGetValue(mutQuarantineProps, kLSQuarantineOriginURLKey) && referrerURL) {
     ::CFDictionarySetValue(mutQuarantineProps, kLSQuarantineOriginURLKey, referrerURL);
   }
 
-  if (!::CFDictionaryGetValue(mutQuarantineProps, kLSQuarantineDataURLKey)) {
+  if (!::CFDictionaryGetValue(mutQuarantineProps, kLSQuarantineDataURLKey) && sourceURL) {
     ::CFDictionarySetValue(mutQuarantineProps, kLSQuarantineDataURLKey, sourceURL);
   }
 
   // Set quarantine properties on file.
   ::CFURLSetResourcePropertyForKey(fileURL,
                                    quarantinePropKey,
                                    mutQuarantineProps,
                                    NULL);