From 39599e3e2ea1bc2ce9ec1ce3aac4cf0d2c975d8c Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 25 Jul 2023 20:22:44 -0400 Subject: [PATCH] cwCommonImpl.h/cpp : Added #include . Check for null label in labelToId() --- cwCommonImpl.cpp | 8 +++++--- cwCommonImpl.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cwCommonImpl.cpp b/cwCommonImpl.cpp index 2662132..b7aed68 100644 --- a/cwCommonImpl.cpp +++ b/cwCommonImpl.cpp @@ -28,9 +28,11 @@ const char* cw::idToLabel( const idLabelPair_t* array, unsigned id, unsigned eol unsigned cw::labelToId( const idLabelPair_t* array, const char* label, unsigned eolId ) { const idLabelPair_t* p = array; - for(; p->id != eolId; ++p) - if( std::strcmp(label,p->label) == 0 ) - return p->id; + + if( label != nullptr ) + for(; p->id != eolId; ++p) + if( std::strcmp(label,p->label) == 0 ) + return p->id; return eolId; } diff --git a/cwCommonImpl.h b/cwCommonImpl.h index 0444dbd..438e948 100644 --- a/cwCommonImpl.h +++ b/cwCommonImpl.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -151,7 +152,7 @@ namespace cw cwAssert( h.p != nullptr ); return h.p; } - + typedef struct idLabelPair_str { unsigned id;