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;