Guard string assignment

Visual Studio 2005 fired an assert on the negative self tests because the SecByteBlock was 0-sized and returned a null pointer.
pull/398/head
Jeffrey Walton 2017-03-19 22:13:12 -04:00
parent e7fa88083c
commit 0c6510b0a5
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 4 additions and 1 deletions

View File

@ -171,7 +171,10 @@ size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte as
SecByteBlock temp(bc); SecByteBlock temp(bc);
if (bc != bt.Get(temp, bc)) if (bc != bt.Get(temp, bc))
BERDecodeError(); BERDecodeError();
str.assign((char *)temp.begin(), bc); if (bc)
str.assign((char *)temp.begin(), bc);
else
str.clear();
return bc; return bc;
} }