Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxcodec/jbig2/JBig2_SddProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_SddProc.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 goto failed; | 242 goto failed; |
| 243 } | 243 } |
| 244 if (EXRUNLENGTH != 0) { | 244 if (EXRUNLENGTH != 0) { |
| 245 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { | 245 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { |
| 246 EXFLAGS[I] = CUREXFLAG; | 246 EXFLAGS[I] = CUREXFLAG; |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 EXINDEX = EXINDEX + EXRUNLENGTH; | 249 EXINDEX = EXINDEX + EXRUNLENGTH; |
| 250 CUREXFLAG = !CUREXFLAG; | 250 CUREXFLAG = !CUREXFLAG; |
| 251 } | 251 } |
| 252 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.
| |
| 253 FX_Free(EXFLAGS); | |
| 254 goto failed; | |
| 255 } | |
| 256 | |
| 252 pDict.reset(new CJBig2_SymbolDict); | 257 pDict.reset(new CJBig2_SymbolDict); |
| 253 I = J = 0; | 258 I = J = 0; |
| 254 for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) { | 259 for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) { |
| 255 if (EXFLAGS[I] && J < SDNUMEXSYMS) { | 260 if (EXFLAGS[I] && J < SDNUMEXSYMS) { |
| 256 if (I < SDNUMINSYMS) { | 261 if (I < SDNUMINSYMS) { |
| 257 pDict->AddImage(SDINSYMS[I] ? new CJBig2_Image(*SDINSYMS[I]) : nullptr); | 262 pDict->AddImage(SDINSYMS[I] ? new CJBig2_Image(*SDINSYMS[I]) : nullptr); |
| 258 } else { | 263 } else { |
| 259 pDict->AddImage(SDNEWSYMS[I - SDNUMINSYMS]); | 264 pDict->AddImage(SDNEWSYMS[I - SDNUMINSYMS]); |
| 260 } | 265 } |
| 261 ++J; | 266 ++J; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 goto failed; | 570 goto failed; |
| 566 } | 571 } |
| 567 if (EXRUNLENGTH != 0) { | 572 if (EXRUNLENGTH != 0) { |
| 568 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { | 573 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { |
| 569 EXFLAGS[I] = CUREXFLAG; | 574 EXFLAGS[I] = CUREXFLAG; |
| 570 } | 575 } |
| 571 } | 576 } |
| 572 EXINDEX = EXINDEX + EXRUNLENGTH; | 577 EXINDEX = EXINDEX + EXRUNLENGTH; |
| 573 CUREXFLAG = !CUREXFLAG; | 578 CUREXFLAG = !CUREXFLAG; |
| 574 } | 579 } |
| 580 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.
| |
| 581 FX_Free(EXFLAGS); | |
| 582 goto failed; | |
| 583 } | |
| 584 | |
| 575 I = J = 0; | 585 I = J = 0; |
| 576 for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) { | 586 for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) { |
| 577 if (EXFLAGS[I] && J < SDNUMEXSYMS) { | 587 if (EXFLAGS[I] && J < SDNUMEXSYMS) { |
| 578 if (I < SDNUMINSYMS) { | 588 if (I < SDNUMINSYMS) { |
| 579 pDict->AddImage(SDINSYMS[I] ? new CJBig2_Image(*SDINSYMS[I]) : nullptr); | 589 pDict->AddImage(SDINSYMS[I] ? new CJBig2_Image(*SDINSYMS[I]) : nullptr); |
| 580 } else { | 590 } else { |
| 581 pDict->AddImage(SDNEWSYMS[I - SDNUMINSYMS]); | 591 pDict->AddImage(SDNEWSYMS[I - SDNUMINSYMS]); |
| 582 } | 592 } |
| 583 ++J; | 593 ++J; |
| 584 } else if (!EXFLAGS[I] && I >= SDNUMINSYMS) { | 594 } else if (!EXFLAGS[I] && I >= SDNUMINSYMS) { |
| 585 delete SDNEWSYMS[I - SDNUMINSYMS]; | 595 delete SDNEWSYMS[I - SDNUMINSYMS]; |
| 586 } | 596 } |
| 587 } | 597 } |
| 588 FX_Free(EXFLAGS); | 598 FX_Free(EXFLAGS); |
| 589 FX_Free(SDNEWSYMS); | 599 FX_Free(SDNEWSYMS); |
| 590 if (SDREFAGG == 0) { | 600 if (SDREFAGG == 0) { |
| 591 FX_Free(SDNEWSYMWIDTHS); | 601 FX_Free(SDNEWSYMWIDTHS); |
| 592 } | 602 } |
| 593 return pDict.release(); | 603 return pDict.release(); |
| 594 failed: | 604 failed: |
| 595 for (I = 0; I < NSYMSDECODED; I++) { | 605 for (I = 0; I < NSYMSDECODED; I++) { |
| 596 delete SDNEWSYMS[I]; | 606 delete SDNEWSYMS[I]; |
| 597 } | 607 } |
| 598 FX_Free(SDNEWSYMS); | 608 FX_Free(SDNEWSYMS); |
| 599 if (SDREFAGG == 0) { | 609 if (SDREFAGG == 0) { |
| 600 FX_Free(SDNEWSYMWIDTHS); | 610 FX_Free(SDNEWSYMWIDTHS); |
| 601 } | 611 } |
| 602 return nullptr; | 612 return nullptr; |
| 603 } | 613 } |
| OLD | NEW |