--- eboard-1.1.1.orig/ntext.cc +++ eboard-1.1.1/ntext.cc @@ -237,6 +237,7 @@ void NText::append(const char *text, int len, int color) { int i; NLine *nl; + char buf[len + 1]; char *p; if (len < 0) { @@ -244,11 +245,14 @@ return; } - p = strchr(text, '\n'); + strncpy(buf, text, len); + buf[len] = '\0'; + + p = strchr(buf, '\n'); if (p!=NULL) { *p = 0; - i = strlen(text); - nl = new NLine(text, color); + i = strlen(buf); + nl = new NLine(buf, color); *p = '\n'; lines.push_back(nl); formatLine(lines.size()-1); @@ -257,7 +261,7 @@ } // if search for \n failed, this is a single line - nl = new NLine(text, color); + nl = new NLine(buf, color); lines.push_back(nl); formatLine(lines.size()-1); discardExcess();