Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5290 in orxonox.OLD


Ignore:
Timestamp:
Oct 6, 2005, 11:41:42 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed issue with the overlaping char-arrays in the Shell's Buffer

Location:
trunk/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine.cc

    r5289 r5290  
    814814  // first remove all the remaining Texts (if any).
    815815  tList<BaseObject>* textList = ClassList::getList(CL_TEXT);
    816   if (text != NULL)
     816  if (textList != NULL)
    817817  {
    818818    tIterator<BaseObject>* textIterator = textList->getIterator();
  • trunk/src/lib/shell/shell_buffer.cc

    r5254 r5290  
    134134void ShellBuffer::addBufferLine(const char* line, va_list arguments)
    135135{
    136   vsprintf(this->bufferArray, line, arguments);
    137 
    138136  char* inputEnd;
    139137  char* newLineBegin;
    140138  char* newLineEnd;
    141139
    142    // check if we have something left in the buffers
     140  // copy the output to the bufferArray
     141  vsprintf(this->bufferArray, line, arguments);
     142
     143  // check if we have something left in the buffers
     144  // if so, append the new String to this one.
    143145  if (unlikely(this->keepBuffer))
    144146  {
    145147    strcat(this->keepBufferArray, this->bufferArray);
    146     inputEnd = this->keepBufferArray + strlen(this->keepBufferArray);
     148    inputEnd = this->keepBufferArray + strlen(this->bufferArray);
    147149    newLineBegin = this->keepBufferArray;
    148150    this->keepBuffer = false;
     
    154156  }
    155157
    156    // adding all the new Lines
    157   while (newLineBegin < inputEnd )
     158  // adding all the new Lines
     159  while (newLineBegin < inputEnd)
    158160  {
    159161    newLineEnd = strchr(newLineBegin, '\n');
    160     if (newLineEnd != NULL && *newLineEnd == '\n')
     162    if (likely(newLineEnd != NULL && *newLineEnd == '\n'))
    161163      *newLineEnd = '\0';
    162164    else
    163165    {
    164 //       newLineEnd = newLineBegin + strlen(newLineBegin);
    165166      unsigned int len = strlen(newLineBegin);
    166       strncpy(this->keepBufferArray, newLineBegin, len);
     167      char* copyBuffer = new char[len+1];
     168      strcpy(copyBuffer, newLineBegin);
     169      strncpy(this->keepBufferArray, copyBuffer, len);
     170      delete[] copyBuffer;
    167171      this->keepBufferArray[len] = '\0';
    168172      this->keepBuffer = true;
Note: See TracChangeset for help on using the changeset viewer.