diff options
author | Ian Rogers <irogers@google.com> | 2021-03-31 21:37:14 -0700 |
---|---|---|
committer | Mike Leach <mike.leach@linaro.org> | 2021-05-17 15:35:19 +0100 |
commit | fef1cd676aaff1b21b39184415cb87a5663d650e (patch) | |
tree | 0093ac206172ed18c84b82510dde0b0bf0abd4d5 | |
parent | 853da282523691105288f22a20103ea93e816c0b (diff) | |
download | OpenCSD-fef1cd676aaff1b21b39184415cb87a5663d650e.tar.gz |
opencsd: Avoid uninitialized read
As registerDecoderTypeByName is called during the constructor the not
yet initialized m_builtInProtocol may be read. Move initialization to
the initializer list and make const for good measure.
This issue was caught by LLVM's memory sanitizer.
-rw-r--r-- | decoder/include/common/ocsd_dcd_mngr.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/decoder/include/common/ocsd_dcd_mngr.h b/decoder/include/common/ocsd_dcd_mngr.h index 3b9ba97..34c4ef1 100644 --- a/decoder/include/common/ocsd_dcd_mngr.h +++ b/decoder/include/common/ocsd_dcd_mngr.h @@ -80,16 +80,16 @@ public: private: - ocsd_trace_protocol_t m_builtInProtocol; //!< Protocol ID if built in type. + const ocsd_trace_protocol_t m_builtInProtocol; //!< Protocol ID if built in type. }; template <class P, class Pt, class Pc> -DecoderMngrBase<P,Pt,Pc>::DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol) + DecoderMngrBase<P,Pt,Pc>::DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol) : + m_builtInProtocol(builtInProtocol) { OcsdLibDcdRegister *pDcdReg = OcsdLibDcdRegister::getDecoderRegister(); if(pDcdReg) pDcdReg->registerDecoderTypeByName(decoderTypeName,this); - m_builtInProtocol = builtInProtocol; } template <class P, class Pt, class Pc> |