A method returned with false after some days of running (Arduino mega, enc28j60)

I create a main controller for my room powered by an Arduino Mega, which monitor temperature sensors, relays, led strips etc... and controllable from the internet (using the ethercard library with the tcpSend(); method), serial port and ir. It worked fine for months without any crash, problem or similar but a few weeks ago have a problem with the internet control.

void loop(){
  ether.packetLoop(ether.packetReceive());
  const char* reply = ether.tcpReply(session);
  if (reply != 0) { 
     if (check_response(reply, "200 OK")) {

// the response handled here

    }
    else Serial.println(reply);
}

The check_response method examine the incoming http response from the webserver (simple php server using Apache webserver) whatever it contains the "200 OK" which means the request handled successfully, else print the reply to the serial monitor and skip the handle. After running the program for 1-2 days without any problem the check_response(reply, "200 OK") method almost every time return with false value. I opened the Serial monitor to check the response but that always contains the "200 OK" in the header. The restart always solved the problem for some days. Is anybody have any suggestion what's wrong with this code?

The method:

bool check_response(String response, String sub)
{
  if (response.indexOf(sub) > 0)
    return true;
  else
    return false;
}

The check_response returned with false for this response:

HTTP/1.1 200 OK
Date: Mon, 13 Nov 2017 10:35:40 GMT
Server: Apache/2.4.25 (Debian)
Content-Length: 8
Keep-Alive: timeout=10, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

00000000

P.S. Sorry for my bad English.

In general it is better to post all your code rather than just guess where you think the problem might be. However, in all likelihood, the problem is that you are using the String class which may cause memory fragmentation and eventual allocation failure. Rewrite your code to use simple C style strings and see if that improves things.

arduarn: In general it is better to post all your code rather than just guess where you think the problem might be. However, in all likelihood, the problem is that you are using the String class which may cause memory fragmentation and eventual allocation failure. Rewrite your code to use simple C style strings and see if that improves things.

Thank you, that's solved my problem.