Bug 1219501 - In imagelib, initialize the number of cores to at least 1 in case of error. r=seth, a=ritu
authorTimothy Nikkel <tnikkel@gmail.com>
Sun, 01 Nov 2015 11:45:40 -0600
changeset 305407 950cfbeec0ee4f08170a722b825ff35c3bff967c
parent 305406 cec904efab0a7dc37d29bccc922a67c756cfb47b
child 305408 6546a42a53fff12ea85882d29214ecdf4ff5e7cf
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, ritu
bugs1219501
milestone44.0a2
Bug 1219501 - In imagelib, initialize the number of cores to at least 1 in case of error. r=seth, a=ritu PR_GetNumberOfProcessors returns -1 in case of error, which is MAXUINT32 when turned into an unsigned int like sNumCores.
image/DecodePool.cpp
--- a/image/DecodePool.cpp
+++ b/image/DecodePool.cpp
@@ -297,17 +297,17 @@ public:
 private:
   RefPtr<DecodePoolImpl> mImpl;
 };
 
 /* static */ void
 DecodePool::Initialize()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  sNumCores = PR_GetNumberOfProcessors();
+  sNumCores = max<int32_t>(PR_GetNumberOfProcessors(), 1);
   DecodePool::Singleton();
 }
 
 /* static */ DecodePool*
 DecodePool::Singleton()
 {
   if (!sSingleton) {
     MOZ_ASSERT(NS_IsMainThread());