Fixed handling of empty URLs.

The code to trim spaces from the end of the URL behaved undefined if the URL was empty. That scenario is far from hypothetic as i.e. pressing the 'back' button with no (more) entry in the history yields an empty URL.
This commit is contained in:
Oliver Schmidt 2015-06-04 22:00:52 +02:00
parent 8b0a7a697f
commit 448fa88ad8

View File

@ -308,10 +308,13 @@ open_url(void)
static uip_ipaddr_t addr; static uip_ipaddr_t addr;
/* Trim off any spaces in the end of the url. */ /* Trim off any spaces in the end of the url. */
urlptr = url + strlen(url) - 1; urlptr = url + strlen(url);
while(*urlptr == ' ' && urlptr > url) { while(urlptr > url) {
*urlptr = 0; if(*(urlptr - 1) == ' ') {
--urlptr; *--urlptr = 0;
} else {
break;
}
} }
/* Don't even try to go further if the URL is empty. */ /* Don't even try to go further if the URL is empty. */