[libbluray-devel] BDGraphics.drawImageN(): limit source rectangle to source image

hpi1 git at videolan.org
Mon Jun 23 09:47:33 CEST 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Jun 23 10:46:56 2014 +0300| [317d41122d985903d6313dbd7b8763d428dfa465] | committer: hpi1

BDGraphics.drawImageN(): limit source rectangle to source image

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=317d41122d985903d6313dbd7b8763d428dfa465
---

 ChangeLog                                           |    2 ++
 src/libbluray/bdj/java/java/awt/BDGraphicsBase.java |    8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 7b54b46..c8a6d78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+- Fix out of array bounds exception in some BD-J menus
+
 2013-05-27: Version 0.6.0
 - Improved BD-J support (Most BD-J discs are correctly played).
 - Mark BD-J titles supported in BLURAY_DISC_INFO if BD-J is functional.
diff --git a/src/libbluray/bdj/java/java/awt/BDGraphicsBase.java b/src/libbluray/bdj/java/java/awt/BDGraphicsBase.java
index e8ddb7b..d0a53c3 100644
--- a/src/libbluray/bdj/java/java/awt/BDGraphicsBase.java
+++ b/src/libbluray/bdj/java/java/awt/BDGraphicsBase.java
@@ -1037,6 +1037,14 @@ abstract class BDGraphicsBase extends Graphics2D implements ConstrainableGraphic
         if (dw < 0) dw = bdImage.width;
         if (dh < 0) dh = bdImage.height;
 
+        /* limit source rectangle width / height to source image */
+        if (sx + sw > bdImage.width) {
+            sw = bdImage.width - sx;
+        }
+        if (sy + sh > bdImage.height) {
+            sh = bdImage.height - sy;
+        }
+
         int   stride   = bdImage.width;
         int[] rgbArray = bdImage.getBdBackBuffer();
         int   bgColor  = 0;



More information about the libbluray-devel mailing list