Bug 1310518 - fix crashes when downloading files without referrer/source URL, r?mstange draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 28 Oct 2016 17:38:29 +0100
changeset 431025 24a3421359537bb8807a4502fd8ed8a426aa6d6f
parent 428241 5639a9f476d08f300c079117e61697f5026b6367
child 535348 7534974f212697a56e98cb2d70aa2a51c94e3d19
push id33985
push usergijskruitbosch@gmail.com
push dateFri, 28 Oct 2016 16:38:56 +0000
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);