Make sure there is only one empty string
This commit is contained in:
parent
7c020d14bc
commit
1942b2840b
1 changed files with 6 additions and 1 deletions
|
@ -210,6 +210,11 @@ ManagedString::ManagedString(const ManagedString &s1, const ManagedString &s2)
|
|||
*/
|
||||
ManagedString::ManagedString(PacketBuffer buffer)
|
||||
{
|
||||
if (buffer.length() == 0) {
|
||||
initEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate a new buffer ( just in case the data is not NULL terminated).
|
||||
ptr = (StringData*) malloc(4+buffer.length()+1);
|
||||
ptr->init();
|
||||
|
@ -238,7 +243,7 @@ ManagedString::ManagedString(PacketBuffer buffer)
|
|||
ManagedString::ManagedString(const char *str, const int16_t length)
|
||||
{
|
||||
// Sanity check. Return EmptyString for anything distasteful
|
||||
if (str == NULL || *str == 0 || (uint16_t)length > strlen(str)) // XXX length should be unsigned on the interface
|
||||
if (str == NULL || *str == 0 || length == 0 || (uint16_t)length > strlen(str)) // XXX length should be unsigned on the interface
|
||||
{
|
||||
initEmpty();
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue