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

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_SymbolDict.h

Issue 1388203003: Sanitize CJBig2_SymbolDict's memory usage. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: more checks Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_ 7 #ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_
8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_ 8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_
9 9
10 #include <vector>
11
10 #include "../../../../third_party/base/nonstd_unique_ptr.h" 12 #include "../../../../third_party/base/nonstd_unique_ptr.h"
11 #include "../../../include/fxcrt/fx_basic.h" 13 #include "../../../include/fxcrt/fx_basic.h"
14 #include "JBig2_ArithDecoder.h"
12 #include "JBig2_List.h" 15 #include "JBig2_List.h"
13 16
14 class CJBig2_Image; 17 class CJBig2_Image;
15 struct JBig2ArithCtx;
16 18
17 class CJBig2_SymbolDict { 19 class CJBig2_SymbolDict {
18 public: 20 public:
19 CJBig2_SymbolDict(); 21 CJBig2_SymbolDict();
20 ~CJBig2_SymbolDict(); 22 ~CJBig2_SymbolDict();
21 23
22 nonstd::unique_ptr<CJBig2_SymbolDict> DeepCopy() const; 24 nonstd::unique_ptr<CJBig2_SymbolDict> DeepCopy() const;
23 25
24 // Takes ownership of |image|. 26 // Takes ownership of |image|.
25 void AddImage(CJBig2_Image* image) { m_SDEXSYMS.push_back(image); } 27 void AddImage(CJBig2_Image* image) { m_SDEXSYMS.push_back(image); }
26 28
27 size_t NumImages() const { return m_SDEXSYMS.size(); } 29 size_t NumImages() const { return m_SDEXSYMS.size(); }
28 CJBig2_Image* GetImage(size_t index) const { return m_SDEXSYMS.get(index); } 30 CJBig2_Image* GetImage(size_t index) const { return m_SDEXSYMS.get(index); }
29 31
30 public: 32 const std::vector<JBig2ArithCtx>& GbContext() const { return m_gbContext; }
31 FX_BOOL m_bContextRetained; 33 const std::vector<JBig2ArithCtx>& GrContext() const { return m_grContext; }
32 JBig2ArithCtx* m_gbContext; 34
33 JBig2ArithCtx* m_grContext; 35 void SetGbContext(const std::vector<JBig2ArithCtx>& gbContext) {
36 m_gbContext = gbContext;
Tom Sepez 2015/10/09 16:10:52 maybe std::vector<>&& and use nonstd::move when c
Lei Zhang 2015/10/09 18:59:52 +thakis - I thought we don't do that yet?
Nico 2015/10/09 20:23:24 chromium-cpp.appspot.com hopefully applies to pdfi
37 }
38 void SetGrContext(const std::vector<JBig2ArithCtx>& grContext) {
39 m_grContext = grContext;
40 }
34 41
35 private: 42 private:
43 std::vector<JBig2ArithCtx> m_gbContext;
44 std::vector<JBig2ArithCtx> m_grContext;
36 CJBig2_List<CJBig2_Image> m_SDEXSYMS; 45 CJBig2_List<CJBig2_Image> m_SDEXSYMS;
37 }; 46 };
38 47
39 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_ 48 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_SYMBOLDICT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698