OSDN Git Service

Resources: fix race with creating theme
authorAdam Lesinski <adamlesinski@google.com>
Tue, 23 May 2017 20:14:54 +0000 (13:14 -0700)
committerAdam Lesinski <adamlesinski@google.com>
Tue, 23 May 2017 20:14:54 +0000 (13:14 -0700)
Bug: 38353957
Test: none
Change-Id: Id78770b475b979635da6a4067db6269e3a1b04d6

core/java/android/content/res/Resources.java

index b559604..e525ab3 100644 (file)
@@ -1760,7 +1760,9 @@ public class Resources {
     public final Theme newTheme() {
         Theme theme = new Theme();
         theme.setImpl(mResourcesImpl.newThemeImpl());
-        mThemeRefs.add(new WeakReference<>(theme));
+        synchronized (mThemeRefs) {
+            mThemeRefs.add(new WeakReference<>(theme));
+        }
         return theme;
     }