Made CharArray::DataOwnData::assign() in 'libsi' more robust against invalid data and changed CharArray::DataOwnData::Delete() so that it sets 'size' and 'data' to 0

This commit is contained in:
Klaus Schmidinger
2006-02-18 11:21:00 +01:00
parent b8cdca858b
commit 273d6c53a6
3 changed files with 10 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* $Id: util.c 1.6 2006/02/18 10:38:20 kls Exp $
* $Id: util.c 1.7 2006/02/18 11:17:50 kls Exp $
* *
***************************************************************************/
@@ -119,6 +119,8 @@ CharArray::DataOwnData::~DataOwnData() {
void CharArray::DataOwnData::assign(const unsigned char*d, int s) {
Delete();
if (!d || s > 100000 || s <= 0) // ultimate plausibility check
return;
size=s;
unsigned char *newdata=new unsigned char[size];
memcpy(newdata, d, size);
@@ -127,6 +129,8 @@ void CharArray::DataOwnData::assign(const unsigned char*d, int s) {
void CharArray::DataOwnData::Delete() {
delete[] data;
size=0;
data=0;
}
CharArray::DataForeignData::~DataForeignData() {