Important update:
- LiteProtocolCore: - Bug fix: NewCommandStr() cannot shrink CommandStr on CreateCommand - Bug fix: AppendParam() cannot pass NULL string value
This commit is contained in:
@@ -196,6 +196,7 @@ bool CLiteProtocol::NewCommandStr()
|
||||
free( CommandStr );
|
||||
CommandStr = NULL;
|
||||
BufferSize = 0;
|
||||
Length = 0;
|
||||
};
|
||||
IncCommandStr( 14 );
|
||||
|
||||
@@ -346,21 +347,31 @@ bool CLiteProtocol::AppendParam( const char * pString, const int pLength )
|
||||
int StringLen;
|
||||
|
||||
// Check if valid
|
||||
if (!pString)
|
||||
return false;
|
||||
if (!pLength || (!pString && (pLength == -1)))
|
||||
{
|
||||
// Increase string length if required
|
||||
StringLen = 0;
|
||||
IncCommandStr( Length + 1 );
|
||||
|
||||
// Increase string length if required
|
||||
StringLen = (pLength < 0)? strlen(pString) : pLength;
|
||||
IncCommandStr( Length + StringLen+1 );
|
||||
// Copy string
|
||||
CommandStr[CurrPos+StringLen] = Separator;
|
||||
Length += 1; // Allow for separator character
|
||||
}
|
||||
else
|
||||
{
|
||||
// Increase string length if required
|
||||
StringLen = (pLength < 0)? strlen(pString) : pLength;
|
||||
IncCommandStr( Length + StringLen+1 );
|
||||
|
||||
// Copy string
|
||||
memcpy( &CommandStr[CurrPos], (char*)pString, StringLen );
|
||||
CommandStr[CurrPos+StringLen] = Separator;
|
||||
Length = Length + StringLen + 1; // Allow for separator character
|
||||
// Copy string
|
||||
memcpy( &CommandStr[CurrPos], (char*)pString, StringLen );
|
||||
CommandStr[CurrPos+StringLen] = Separator;
|
||||
Length = Length + StringLen + 1; // Allow for separator character
|
||||
}
|
||||
|
||||
// Move pointer to end and set end char
|
||||
CurrParam++;
|
||||
CurrPos = CurrPos + StringLen + 1; // Allow for separator character
|
||||
CurrPos += StringLen + 1; // Allow for separator character
|
||||
CommandStr[CurrPos] = EndChar;
|
||||
|
||||
// Update references
|
||||
|
||||
Reference in New Issue
Block a user