aom_dsp: Asan fix in aom_film_grain_table_lookup

Use the cached end_time of the entry to avoid heap-after-use error.

BUG=aomedia:3000

Change-Id: Ic37c910ff08809cf75552d5b32c80e02137f7cce
(cherry picked from commit d2a6356c57f0f680086f3dcc1961d233eddb3172)
diff --git a/aom_dsp/grain_table.c b/aom_dsp/grain_table.c
index e03f04d..66c604e 100644
--- a/aom_dsp/grain_table.c
+++ b/aom_dsp/grain_table.c
@@ -244,7 +244,7 @@
       // If segments aren't aligned, delete from the beggining of subsequent
       // segments
       if (end_time > entry_end_time) {
-        aom_film_grain_table_lookup(t, entry->end_time, end_time, 1, 0);
+        aom_film_grain_table_lookup(t, entry_end_time, end_time, 1, 0);
       }
       return 1;
     }
diff --git a/test/film_grain_table_test.cc b/test/film_grain_table_test.cc
index 524d67d..31fb908 100644
--- a/test/film_grain_table_test.cc
+++ b/test/film_grain_table_test.cc
@@ -101,6 +101,20 @@
   aom_film_grain_table_free(&table);
 }
 
+TEST(FilmGrainTableTest, AddSingleSegmentRemoveBiggerSegment) {
+  aom_film_grain_table_t table;
+  aom_film_grain_t grain;
+
+  memset(&table, 0, sizeof(table));
+
+  aom_film_grain_table_append(&table, 0, 1000, film_grain_test_vectors + 0);
+  EXPECT_TRUE(aom_film_grain_table_lookup(&table, 0, 1100, true, &grain));
+
+  EXPECT_EQ(0, table.head);
+  EXPECT_EQ(0, table.tail);
+  aom_film_grain_table_free(&table);
+}
+
 TEST(FilmGrainTableTest, SplitSingleSegment) {
   aom_film_grain_table_t table;
   aom_film_grain_t grain;