Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: core/fxcodec/jbig2/JBig2_SddProc.cpp

Issue 2419553002: Verify number of ex flags matches number of ex items. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcodec/jbig2/JBig2_SddProc.cpp
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 1a7e96d26b2262ca2d7636a457bcc478d05ae51b..c1904176eb4afcc91bbff8a31bf97b2bb9422848 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -249,6 +249,11 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
EXINDEX = EXINDEX + EXRUNLENGTH;
CUREXFLAG = !CUREXFLAG;
}
+ if (EXINDEX > SDNUMEXSYMS) {
Tom Sepez 2016/10/12 16:27:43 This is fine, but generally when writing this "C-S
kcwu 2016/10/12 16:41:47 Since SDNUMEXSYMS is always zero, this check means
kcwu 2016/10/12 23:49:58 So, please ignore my previous stupid comment.
+ FX_Free(EXFLAGS);
+ goto failed;
+ }
+
pDict.reset(new CJBig2_SymbolDict);
I = J = 0;
for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) {
@@ -572,6 +577,11 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
EXINDEX = EXINDEX + EXRUNLENGTH;
CUREXFLAG = !CUREXFLAG;
}
+ if (EXINDEX > SDNUMEXSYMS) {
kcwu 2016/10/12 23:49:58 As your commit message said, it will leak if the n
dsinclair 2016/10/13 14:12:17 Ack, good point. Fixed.
+ FX_Free(EXFLAGS);
+ goto failed;
+ }
+
I = J = 0;
for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) {
if (EXFLAGS[I] && J < SDNUMEXSYMS) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698