Merge cherrypicks of [2007123, 2089669, 2072002, 2094113, 1989895, 2094094, 2017568, 2054111, 2054025, 2074928, 2066476, 2092431, 2053944, 2095243, 2092549, 2065088, 2007730, 2008313, 2053983, 2025333, 2094716, 2026590, 2059276, 2089422, 2080090] into nyc-mr2-pixel-monthly-release

Change-Id: Iaec82abea20c4dacc41d790bc233bfb5f7da8fbb
diff --git a/gdx/jni/gdx2d/stb_image.h b/gdx/jni/gdx2d/stb_image.h
index d91b308..a9d338a 100644
--- a/gdx/jni/gdx2d/stb_image.h
+++ b/gdx/jni/gdx2d/stb_image.h
@@ -5228,6 +5228,10 @@
                } else if (len < 128) {
                   // Copy next len+1 bytes literally.
                   len++;
+                  if (len >= pixelCount - count) {
+                     STBI_FREE(out);
+                     return stbi__errpuc("corruptfile", "Corrupt PSD file");
+                  }
                   count += len;
                   while (len) {
                      *p = stbi__get8(s);
@@ -5241,6 +5245,10 @@
                   len ^= 0x0FF;
                   len += 2;
                   val = stbi__get8(s);
+                  if (len >= pixelCount - count) {
+                     STBI_FREE(out);
+                     return stbi__errpuc("corruptfile", "Corrupt PSD file");
+                  }
                   count += len;
                   while (len) {
                      *p = val;