Commit eed8d18c authored by multrus's avatar multrus
Browse files

adapt patch, to avoid overflows

parent 867348fd
Loading
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -588,11 +588,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
    ELSE /* if(!hm_cfg) */
    {
        Word16 c, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        UWord32 s;
#else
        UWord16 s;
#endif

        /* Rate flag */
        IF( GT_16( nbbits, 400 ) )
@@ -617,11 +613,8 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
        t = 0;
        move16();
        s = 0;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        move32();
#else
        move16();
#endif

        /* Main Loop through the 2-tuples */
        FOR( k = 0; k < lastnz; k += 2 )
        {
@@ -710,9 +703,9 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
            }

#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = L_shl( s, 4 ); /*Shift old 4 bits*/
            s = L_add( s, c ); /*replace last 4 bits*/
            t = extract_l( L_and( s, 0xFF ) );
            s = shl( s_and( s, 0x0F ), 4 ); /*Shift old 4 bits*/
            s = add( s, c ); /*replace last 4 bits*/
            t = s_and( s, 0xFF );
#else
            s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/
            s = (UWord16) L_add( s, c ); /*replace last 4 bits*/
+4 −20
Original line number Diff line number Diff line
@@ -973,11 +973,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
    {
        Word16 cp;
        Word16 esc_nb, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        UWord32 s;
#else
        UWord16 s;
#endif

        /* Rate flag */
        IF( GT_16( nbbits, 400 ) )
@@ -992,11 +988,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
        }

        s = 0;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        move32();
#else
        move16();
#endif

        /* Find last non-zero tuple */
        /* ensure termination of while loop by dummy value */
@@ -1108,8 +1100,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(

            /*Shift old 4 bits, replace last 4 bits*/
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = L_add( L_shl( s, 4 ), cp );
            t = extract_l( L_and( s, 0xFF ) );
            s = add( shl( s_and( s, 0x0F ), 4 ), cp );
            t = s_and( s, 0xFF );
#else
            s = (UWord16) ( L_add( L_shl( s, 4 ), cp ) );
            t = (UWord16) L_and( s, 0xFF );
@@ -1466,11 +1458,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
    ELSE /* if (!hm_cfg) */
    {
        Word16 esc_nb, cp, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        UWord32 s;
#else
        UWord16 s;
#endif
        Word16 tot_bits2;
        Word16 overflow_flag = 0;
        move16();
@@ -1490,11 +1478,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
        t = 0;
        move16();
        s = 0;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        move32();
#else
        move16();
#endif
        cp = 0;
        move16();
        lastnz = 1;
@@ -1586,8 +1570,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            }
            /*shift old bits and replace last 4 bits*/
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            s = L_add( L_shl( s, 4 ), cp );
            t = extract_l( L_and( s, 0xFF ) );
            s = add( shl( s_and( s, 0x0F ), 4 ), cp );
            t = s_and( s, 0xFF );
#else
            s = (UWord16) L_add( L_shl( s, 4 ), cp );
            t = s_and( s, 0xFF );