[x265] [PATCH] log: fix memory overread issue

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Dec 11 10:22:54 CET 2013


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1386753758 -19800
#      Wed Dec 11 14:52:38 2013 +0530
# Node ID 40895c94da21aed021097f40a62f921c8056ca61
# Parent  a1e7aac486a726ff6951ac7a4b19f902b633737a
log: fix memory overread issue

diff -r a1e7aac486a7 -r 40895c94da21 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Wed Dec 11 14:25:52 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Wed Dec 11 14:52:38 2013 +0530
@@ -356,17 +356,20 @@
     m_temporalSAD      = 0;
 
     // analysis of CU
+#if LOG_CU_STATISTICS
+    int numPartition = cu->getTotalNumPart();
+#endif
 
     if (m_bestCU[0]->getSlice()->getSliceType() == I_SLICE)
     {
         xCompressIntraCU(m_bestCU[0], m_tempCU[0], 0);
 #if LOG_CU_STATISTICS
         int i = 0, part;
-        part = cu->getDepth(i);
         do
         {
             m_log->totalCu++;
-            int next = cu->getTotalNumPart() >> (part * 2);
+            part = cu->getDepth(i);
+            int next = numPartition >> (part * 2);
             if (part == g_maxCUDepth - 1 && cu->getPartitionSize(i) != SIZE_2Nx2N)
             {
                 m_log->cntIntraNxN++;
@@ -380,9 +383,8 @@
                     m_log->cuIntraDistribution[part][cu->getLumaIntraDir()[i]]++;
             }
             i += next;
-            part = cu->getDepth(i);
         }
-        while (part < g_maxCUDepth);
+        while (i < numPartition);
 #endif
     }
     else
@@ -399,11 +401,11 @@
             xCompressCU(m_bestCU[0], m_tempCU[0], 0);
 #if LOG_CU_STATISTICS
         int i = 0, part;
-        part = cu->getDepth(i);
         do
         {
+            part = cu->getDepth(i);
             m_log->cntTotalCu[part]++;
-            int next = cu->getTotalNumPart() >> (part * 2);
+            int next = numPartition >> (part * 2);
             if (cu->isSkipped(i))
             {
                 m_log->cntSkipCu[part]++;
@@ -436,9 +438,8 @@
                 }
             }
             i = i + next;
-            part = cu->getDepth(i);
         }
-        while (part < g_maxCUDepth);
+        while (i < numPartition);
 #endif
     }
 }


More information about the x265-devel mailing list