mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
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:
parent
8b0a7a697f
commit
448fa88ad8
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user