Bug 989538 - GetDefaultStorageName should always initialize the returned storageName. r=janv
authorDave Hylands <dhylands@mozilla.com>
Tue, 01 Apr 2014 15:53:43 -0700
changeset 176728 57d40d0a0abaa81ecfae387aa1e34d5293911bdb
parent 176727 531b122d66449a64a9ab518cde98824b238692b9
child 176729 2ebad9354c3f39305b4fbe2d26123770977cb85f
push id5961
push userdhylands@mozilla.com
push dateWed, 02 Apr 2014 21:34:06 +0000
treeherderb2g-inbound@2ebad9354c3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs989538
milestone31.0a1
Bug 989538 - GetDefaultStorageName should always initialize the returned storageName. r=janv
dom/devicestorage/nsDeviceStorage.cpp
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -3356,17 +3356,22 @@ nsDOMDeviceStorage::GetDefaultStorageNam
   }
 
   // No preferred storage, we'll use the first one (which should be sdcard).
 
   VolumeNameArray volNames;
   GetOrderedVolumeNames(volNames);
   if (volNames.Length() > 0) {
     aStorageName = volNames[0];
-  }
+    return;
+  }
+
+  // No volumes available, return the empty string. This is normal for
+  // b2g-desktop.
+  aStorageName.Truncate();
 }
 
 bool
 nsDOMDeviceStorage::IsAvailable()
 {
   DeviceStorageFile dsf(mStorageType, mStorageName);
   return dsf.IsAvailable();
 }