From 103489879a2277021cb32dcf8e2602541be2fe40 Mon Sep 17 00:00:00 2001 From: SebGDev Date: Tue, 10 Feb 2015 17:18:53 +0100 Subject: [PATCH] Fixed memory leak Old zxing issue 1795: https://code.google.com/p/zxing/issues/detail?id=1795 --- core/src/zxing/common/CharacterSetECI.cpp | 9 +++++---- core/src/zxing/common/CharacterSetECI.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/zxing/common/CharacterSetECI.cpp b/core/src/zxing/common/CharacterSetECI.cpp index 8386208..44a81bb 100644 --- a/core/src/zxing/common/CharacterSetECI.cpp +++ b/core/src/zxing/common/CharacterSetECI.cpp @@ -24,8 +24,8 @@ using std::string; using zxing::common::CharacterSetECI; using zxing::IllegalArgumentException; -std::map CharacterSetECI::VALUE_TO_ECI; -std::map CharacterSetECI::NAME_TO_ECI; +std::map> CharacterSetECI::VALUE_TO_ECI; +std::map> CharacterSetECI::NAME_TO_ECI; const bool CharacterSetECI::inited = CharacterSetECI::init_tables(); @@ -72,11 +72,12 @@ bool CharacterSetECI::init_tables() { CharacterSetECI::CharacterSetECI(int const* values, char const* const* names) : values_(values), names_(names) { + zxing::Ref this_ref(this); for(int const* values = values_; *values != -1; values++) { - VALUE_TO_ECI[*values] = this; + VALUE_TO_ECI[*values] = this_ref; } for(char const* const* names = names_; *names; names++) { - NAME_TO_ECI[string(*names)] = this; + NAME_TO_ECI[string(*names)] = this_ref; } } diff --git a/core/src/zxing/common/CharacterSetECI.h b/core/src/zxing/common/CharacterSetECI.h index 95ea86f..2bf8dc1 100644 --- a/core/src/zxing/common/CharacterSetECI.h +++ b/core/src/zxing/common/CharacterSetECI.h @@ -25,10 +25,10 @@ namespace zxing { namespace common { -class CharacterSetECI { +class CharacterSetECI : public Counted { private: - static std::map VALUE_TO_ECI; - static std::map NAME_TO_ECI; + static std::map> VALUE_TO_ECI; + static std::map> NAME_TO_ECI; static const bool inited; static bool init_tables();