diff options
author | Tim Murray <timmurray@google.com> | 2013-12-03 11:36:03 -0800 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2014-03-20 21:34:21 -0700 |
commit | 7d2a6e85c570e574457d1862c9e16025094d09e7 (patch) | |
tree | 59130f11b0b2db5d1f0bc52eec3745c9665d7648 | |
parent | 5c89f711c8a50563f10daf1771814988582a4af3 (diff) | |
download | rs-kitkat-mr2.2-release.tar.gz |
Fix memory leak due to smart pointer misuse.android-4.4w_r1android-4.4.4_r2.0.1android-4.4.4_r2android-4.4.4_r1.0.1android-4.4.4_r1android-4.4.3_r1.1.0.1android-4.4.3_r1.1android-4.4.3_r1.0.1android-4.4.3_r1kitkat-wearkitkat-mr2.2-releasekitkat-mr2.1-releasekitkat-mr2-releasekitkat-dev
bug 11965932
Change-Id: I982b974b3554b0f4dc7a558107703ff605f580e6
-rw-r--r-- | cpp/BaseObj.cpp | 6 | ||||
-rw-r--r-- | cpp/Element.cpp | 2 | ||||
-rw-r--r-- | cpp/Type.cpp | 2 | ||||
-rw-r--r-- | cpp/rsCppStructs.h | 6 |
4 files changed, 9 insertions, 7 deletions
diff --git a/cpp/BaseObj.cpp b/cpp/BaseObj.cpp index 80d94145..2e0a6377 100644 --- a/cpp/BaseObj.cpp +++ b/cpp/BaseObj.cpp @@ -33,7 +33,7 @@ void * BaseObj::getObjID(sp<const BaseObj> o) { BaseObj::BaseObj(void *id, sp<RS> rs) { - mRS = rs; + mRS = rs.get(); mID = id; } @@ -44,7 +44,9 @@ void BaseObj::checkValid() { } BaseObj::~BaseObj() { - RS::dispatch->ObjDestroy(mRS->getContext(), mID); + if (mRS && mRS->getContext()) { + RS::dispatch->ObjDestroy(mRS->getContext(), mID); + } mRS = NULL; mID = NULL; } diff --git a/cpp/Element.cpp b/cpp/Element.cpp index d3fb29a2..ce846991 100644 --- a/cpp/Element.cpp +++ b/cpp/Element.cpp @@ -358,7 +358,7 @@ bool Element::isCompatible(android::RSC::sp<const Element>e) const { } Element::Builder::Builder(android::RSC::sp<RS> rs) { - mRS = rs; + mRS = rs.get(); mSkipPadding = false; } diff --git a/cpp/Type.cpp b/cpp/Type.cpp index 07da0c5d..d053730f 100644 --- a/cpp/Type.cpp +++ b/cpp/Type.cpp @@ -116,7 +116,7 @@ sp<const Type> Type::create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint3 } Type::Builder::Builder(sp<RS> rs, sp<const Element> e) { - mRS = rs; + mRS = rs.get(); mElement = e; mDimX = 0; mDimY = 0; diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h index 1efd128c..8fb18cd8 100644 --- a/cpp/rsCppStructs.h +++ b/cpp/rsCppStructs.h @@ -260,7 +260,7 @@ public: protected: void *mID; - sp<RS> mRS; + RS* mRS; std::string mName; BaseObj(void *id, sp<RS> rs); @@ -1031,7 +1031,7 @@ public: */ class Builder { private: - sp<RS> mRS; + RS* mRS; std::vector<sp<Element> > mElements; std::vector<std::string> mElementNames; std::vector<uint32_t> mArraySizes; @@ -1285,7 +1285,7 @@ public: class Builder { protected: - sp<RS> mRS; + RS* mRS; uint32_t mDimX; uint32_t mDimY; uint32_t mDimZ; |