diff options
author | James Zern <jzern@google.com> | 2022-04-04 10:47:40 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2022-04-06 21:56:58 -0700 |
commit | 127a4d7c99acdc434369ed80fe629cff978fe87c (patch) | |
tree | daf73b2bcf09183a9f32ea6eec3eb0fc0f1965d3 | |
parent | b2c2d237a441318c426509828ebede89e899174d (diff) | |
download | libwebp-1.0.0.tar.gz |
GetBackwardReferences: fail on alloc error1.0.0
previously failures in the call to
VP8LBackwardReferencesTraceBackwards() would be ignored which, though it
wouldn't result in a crash, would produce non-deterministic output
Change-Id: Id9890a60883c3270ec75e968506d46eea32b76d4
(cherry picked from commit e3cfafaf719c2e163d3548d7a415da96fdff714f)
(cherry picked from commit 20ef03ee351d4ff03fc5ff3ec4804a879d1b9d5c)
(cherry picked from commit 89e226a3c70ae04fe8e1884aa0b291f39adb2fdf)
-rw-r--r-- | src/enc/backward_references_enc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/enc/backward_references_enc.c b/src/enc/backward_references_enc.c index 39230188..b29fc9e9 100644 --- a/src/enc/backward_references_enc.c +++ b/src/enc/backward_references_enc.c @@ -910,13 +910,14 @@ static VP8LBackwardRefs* GetBackwardReferences( quality >= 25) { const VP8LHashChain* const hash_chain_tmp = (lz77_type_best == kLZ77Standard) ? hash_chain : &hash_chain_box; - if (VP8LBackwardReferencesTraceBackwards(width, height, argb, *cache_bits, - hash_chain_tmp, best, worst)) { - double bit_cost_trace; - VP8LHistogramCreate(histo, worst, *cache_bits); - bit_cost_trace = VP8LHistogramEstimateBits(histo); - if (bit_cost_trace < bit_cost_best) best = worst; + double bit_cost_trace; + if (!VP8LBackwardReferencesTraceBackwards(width, height, argb, *cache_bits, + hash_chain_tmp, best, worst)) { + goto Error; } + VP8LHistogramCreate(histo, worst, *cache_bits); + bit_cost_trace = VP8LHistogramEstimateBits(histo); + if (bit_cost_trace < bit_cost_best) best = worst; } BackwardReferences2DLocality(width, best); |