Fixed Packet::reInit printing errors for empty packets.

This commit is contained in:
Thulinma 2014-08-05 16:03:24 +02:00
parent 68245bf74c
commit 9554263e2f

View file

@ -132,13 +132,19 @@ namespace DTSC {
///\param len The length of the data pointed to by data_ ///\param len The length of the data pointed to by data_
///\param noCopy Determines whether to make a copy or not ///\param noCopy Determines whether to make a copy or not
void Packet::reInit(const char * data_, unsigned int len, bool noCopy) { void Packet::reInit(const char * data_, unsigned int len, bool noCopy) {
if (!len){
null();
return;
}
if (!data_) { if (!data_) {
DEBUG_MSG(DLVL_DEVEL, "ReInit received a null pointer with len %d, ignoring", len); DEBUG_MSG(DLVL_DEVEL, "ReInit received a null pointer with len %d, ignoring", len);
null(); null();
return; return;
} }
if (data_[0] != 'D' || data_[1] != 'T') { if (data_[0] != 'D' || data_[1] != 'T') {
DEBUG_MSG(DLVL_HIGH, "ReInit received a pointer that didn't start with 'DT' - data corruption?"); unsigned int twlen = len;
if (twlen > 20){twlen = 20;}
DEBUG_MSG(DLVL_HIGH, "ReInit received a pointer that didn't start with 'DT' but with %s (%u) - data corruption?", JSON::Value(std::string(data_, twlen)).toString().c_str(), len);
null(); null();
return; return;
} }