[Commits] SDL: Fixed rare null pointer dereference

libsdl.org revision control commits-owner at libsdl.org
Mon Sep 24 20:31:34 PDT 2018


details:   https://hg.libsdl.org/SDL/rev/483789136c52
changeset: 12205:483789136c52
user:      Sam Lantinga <slouken at libsdl.org>
date:      Mon Sep 24 20:31:24 2018 -0700
description:
Fixed rare null pointer dereference

diffstat:

 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java |  37 +++++----
 1 files changed, 20 insertions(+), 17 deletions(-)

diffs (64 lines):

diff -r 5486557ca8d9 -r 483789136c52 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Sep 24 16:41:55 2018 -0700
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Sep 24 20:31:24 2018 -0700
@@ -583,7 +583,7 @@
                                         View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                                         View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                                         View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
-                    					View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
+                                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
                             window.getDecorView().setSystemUiVisibility(flags);        
                             window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                             window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
@@ -1512,6 +1512,10 @@
                                int format, int width, int height) {
         Log.v("SDL", "surfaceChanged()");
 
+        if (SDLActivity.mSingleton == null) {
+            return;
+        }
+
         int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default
         switch (format) {
         case PixelFormat.A_8:
@@ -1559,25 +1563,24 @@
 
         mWidth = width;
         mHeight = height;
-		int nDeviceWidth = width;
-		int nDeviceHeight = height;
-		try
-		{
-			if ( android.os.Build.VERSION.SDK_INT >= 17 )
-			{
-				android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
-				mDisplay.getRealMetrics( realMetrics );
-				nDeviceWidth = realMetrics.widthPixels;
-				nDeviceHeight = realMetrics.heightPixels;
-			}
-		}
-		catch ( java.lang.Throwable throwable ) {}
+        int nDeviceWidth = width;
+        int nDeviceHeight = height;
+        try
+        {
+            if ( android.os.Build.VERSION.SDK_INT >= 17 )
+            {
+                android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
+                mDisplay.getRealMetrics( realMetrics );
+                nDeviceWidth = realMetrics.widthPixels;
+                nDeviceHeight = realMetrics.heightPixels;
+            }
+        }
+        catch ( java.lang.Throwable throwable ) {}
 
-		Log.v("SDL", "Window size: " + width + "x" + height);
-		Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
+        Log.v("SDL", "Window size: " + width + "x" + height);
+        Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
         SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
 
-
         boolean skip = false;
         int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
 


More information about the commits mailing list