[libbluray-devel] Fix shift left

hpi1 git at videolan.org
Sun May 15 15:49:36 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun May 15 16:47:03 2016 +0300| [54c6cc3dd8f2be0966410cfe9a2a988bfea672b8] | committer: hpi1

Fix shift left

Implicit conversation may cause signed int when unsigned is expected

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

 src/util/bits.c  |    2 +-
 src/util/macro.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/bits.c b/src/util/bits.c
index 16efce1..850031f 100644
--- a/src/util/bits.c
+++ b/src/util/bits.c
@@ -169,7 +169,7 @@ uint32_t bb_read( BITBUFFER *bb, int i_count )
             return( i_result );
         } else {
             /* less in the buffer than requested */
-           i_result |= (*bb->p&i_mask[bb->i_left]) << -i_shr;
+           i_result |= (unsigned)(*bb->p&i_mask[bb->i_left]) << -i_shr;
            i_count  -= bb->i_left;
            bb->p++;
            bb->i_left = 8;
diff --git a/src/util/macro.h b/src/util/macro.h
index dd6067a..9b8595a 100644
--- a/src/util/macro.h
+++ b/src/util/macro.h
@@ -25,7 +25,7 @@
 
 #define MKINT_BE16(X) ( (X)[0] << 8 | (X)[1] )
 #define MKINT_BE24(X) ( (X)[0] << 16 | (X)[1] << 8 | (X)[2] )
-#define MKINT_BE32(X) ( (X)[0] << 24 | (X)[1] << 16 |  (X)[2] << 8 | (X)[3] )
+#define MKINT_BE32(X) ( (unsigned)((X)[0]) << 24 | (X)[1] << 16 |  (X)[2] << 8 | (X)[3] )
 #define X_FREE(X)     ( free(X), X = NULL )
 
 #define BD_MIN(a,b) ((a)<(b)?(a):(b))



More information about the libbluray-devel mailing list