Hello,

This code crashes with segfault
Qt Code:
  1. QString MainWindowImpl::getIp(QString line)
  2. {
  3. static char ip[1000], s[1000];
  4. strcpy(s, line.toLocal8Bit().constData());
  5. char *p1 = strstr(s, "client ") + 7, *p2 = ip;
  6. while (*p1 && *p1 != ']')
  7. *p2++ = *p1++;
  8. *p2 = 0;
  9. return ip;
To copy to clipboard, switch view to plain text mode 

If I change the line with strstr to:
Qt Code:
  1. char *p1 = s + 7, *p2 = ip;
To copy to clipboard, switch view to plain text mode 
all is well..

I know I can do things the qt way but I want to be portable with plain c strings.
Thanks.