Browse Source

Don't call strncpy when src == dest

This fixes an error flagged by address sanitizer
Ben Payne 10 years ago
parent
commit
bd49fe3cb0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Engine/source/gui/controls/guiTextCtrl.cpp

+ 1 - 1
Engine/source/gui/controls/guiTextCtrl.cpp

@@ -188,7 +188,7 @@ void GuiTextCtrl::setText(const char *txt)
    if( !mProfile )
    if( !mProfile )
       return;
       return;
    
    
-   if (txt)
+   if (txt && txt != mText)
       dStrncpy(mText, (UTF8*)txt, MAX_STRING_LENGTH);
       dStrncpy(mText, (UTF8*)txt, MAX_STRING_LENGTH);
    mText[MAX_STRING_LENGTH] = '\0';
    mText[MAX_STRING_LENGTH] = '\0';