ref: 54827e5782d2e00f2117544201fe2b3dc6e0bce5
parent: cb671194c9ac4068922a971318670c91bf96c906
author: James Zern <jzern@google.com>
date: Fri Sep 14 17:36:26 EDT 2018
vp9,encoder: check pointers before member access verify pointers passed to vp9_cyclic_refresh_free() and vp9_setup_pc_tree() before attempting to free members of the structs. based on the change in libaom: ie41de6b5a AV1FrameSizeTests.LargeValidSizes: avoid segfault. Change-Id: Ib81759923cb442e19f42e6edb4b61171d8799ba6
--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -52,9 +52,11 @@
}
void vp9_cyclic_refresh_free(CYCLIC_REFRESH *cr) {
- vpx_free(cr->map);
- vpx_free(cr->last_coded_q_map);
- vpx_free(cr);
+ if (cr != NULL) {
+ vpx_free(cr->map);
+ vpx_free(cr->last_coded_q_map);
+ vpx_free(cr);
+ }
}
// Check if this coding block, of size bsize, should be considered for refresh
--- a/vp9/encoder/vp9_context_tree.c
+++ b/vp9/encoder/vp9_context_tree.c
@@ -139,17 +139,22 @@
}
void vp9_free_pc_tree(ThreadData *td) {
- const int tree_nodes = 64 + 16 + 4 + 1;
int i;
- // Set up all 4x4 mode contexts
- for (i = 0; i < 64; ++i) free_mode_context(&td->leaf_tree[i]);
+ if (td == NULL) return;
- // Sets up all the leaf nodes in the tree.
- for (i = 0; i < tree_nodes; ++i) free_tree_contexts(&td->pc_tree[i]);
+ if (td->leaf_tree != NULL) {
+ // Set up all 4x4 mode contexts
+ for (i = 0; i < 64; ++i) free_mode_context(&td->leaf_tree[i]);
+ vpx_free(td->leaf_tree);
+ td->leaf_tree = NULL;
+ }
- vpx_free(td->pc_tree);
- td->pc_tree = NULL;
- vpx_free(td->leaf_tree);
- td->leaf_tree = NULL;
+ if (td->pc_tree != NULL) {
+ const int tree_nodes = 64 + 16 + 4 + 1;
+ // Sets up all the leaf nodes in the tree.
+ for (i = 0; i < tree_nodes; ++i) free_tree_contexts(&td->pc_tree[i]);
+ vpx_free(td->pc_tree);
+ td->pc_tree = NULL;
+ }
}