cwUi.cpp : Fix problem where setLogLine() did not reserve enough space to handle decoding escape sequences.
This commit is contained in:
parent
04999f05fc
commit
16bdcca968
15
cwUi.cpp
15
cwUi.cpp
@ -1517,12 +1517,13 @@ cw::rc_t cw::ui::setLogLine( handle_t h, unsigned uuId, const char* text )
|
||||
rc = sendValueString(h,uuId,text);
|
||||
else
|
||||
{
|
||||
int sn = textLength(text);
|
||||
unsigned sn = textLength(text);
|
||||
sn += n + 1;
|
||||
|
||||
char s[ sn ];
|
||||
// alloc. a lot of extra space to cover the space need for the '\' escape character
|
||||
char s[ sn*2 ];
|
||||
unsigned i,j;
|
||||
for( i=0,j=0; text[i]; ++i,++j)
|
||||
for( i=0,j=0; text[i] && j<sn; ++i,++j)
|
||||
{
|
||||
char ch = text[i];
|
||||
bool escape_fl = true;
|
||||
@ -1543,11 +1544,14 @@ cw::rc_t cw::ui::setLogLine( handle_t h, unsigned uuId, const char* text )
|
||||
if( escape_fl )
|
||||
s[j++] = '\\';
|
||||
|
||||
if( j < sn )
|
||||
s[j] = ch;
|
||||
}
|
||||
|
||||
s[sn-1] = 0;
|
||||
|
||||
|
||||
|
||||
//printf("%s %s\n",text,s);
|
||||
|
||||
rc = sendValueString(h,uuId,s);
|
||||
@ -1782,10 +1786,11 @@ void cw::ui::report( handle_t h )
|
||||
{
|
||||
const ele_t* e = p->eleA[i];
|
||||
|
||||
|
||||
unsigned parUuId = e->phys_parent==NULL ? kInvalidId : e->phys_parent->uuId;
|
||||
const char* parEleName = e->phys_parent==NULL || e->phys_parent->eleName == NULL ? "" : e->phys_parent->eleName;
|
||||
|
||||
printf("uu:%5i app:%5i %20s : parent uu:%5i app:%5i %20s ", e->uuId, e->appId, e->eleName == NULL ? "" : e->eleName, parUuId, e->logical_parent->appId, parEleName );
|
||||
unsigned logParentAppId = e->logical_parent==NULL ? kInvalidId : e->logical_parent->appId;
|
||||
printf("uu:%5i app:%5i chan:%5i %20s : parent uu:%5i app:%5i %20s ", e->uuId, e->appId, e->chanId, e->eleName == NULL ? "" : e->eleName, parUuId, logParentAppId, parEleName );
|
||||
|
||||
for(unsigned i=0; i<e->attr->child_count(); ++i)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user