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
1 changed files with 7 additions and 4 deletions

View File

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