Fix memeory leak in alloccommon.c

Always assume there are MAX_MB_PLANE planes when freeing dynamically
allocated memory. This can make sure no memory leak happens.

BUG=b/75016317

Change-Id: I5bcd1672cf064657d22fc0047218e38ee7b4bc90
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index f8eca2c..0de5683 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -168,13 +168,12 @@
 }
 
 void av1_free_restoration_buffers(AV1_COMMON *cm) {
-  const int num_planes = av1_num_planes(cm);
   int p;
-  for (p = 0; p < num_planes; ++p)
+  for (p = 0; p < MAX_MB_PLANE; ++p)
     av1_free_restoration_struct(&cm->rst_info[p]);
   aom_free(cm->rst_tmpbuf);
   cm->rst_tmpbuf = NULL;
-  for (p = 0; p < num_planes; ++p) {
+  for (p = 0; p < MAX_MB_PLANE; ++p) {
     RestorationStripeBoundaries *boundaries = &cm->rst_info[p].boundaries;
     aom_free(boundaries->stripe_boundary_above);
     aom_free(boundaries->stripe_boundary_below);
@@ -209,7 +208,6 @@
 #endif  // LOOP_FILTER_BITMASK
 
 void av1_free_context_buffers(AV1_COMMON *cm) {
-  const int num_planes = av1_num_planes(cm);
   int i;
   cm->free_mi(cm);
 
@@ -220,7 +218,7 @@
 #if !CONFIG_SEGMENT_PRED_LAST
   free_seg_map(cm);
 #endif
-  for (i = 0; i < num_planes; i++) {
+  for (i = 0; i < MAX_MB_PLANE; i++) {
     aom_free(cm->above_context[i]);
     cm->above_context[i] = NULL;
   }
@@ -230,7 +228,7 @@
   aom_free(cm->above_txfm_context);
   cm->above_txfm_context = NULL;
 
-  for (i = 0; i < num_planes; ++i) {
+  for (i = 0; i < MAX_MB_PLANE; ++i) {
     aom_free(cm->top_txfm_context[i]);
     cm->top_txfm_context[i] = NULL;
   }