From 448fa88ad81c7337ad61450dbc45d99575bc35cd Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 4 Jun 2015 22:00:52 +0200
Subject: [PATCH] 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.
---
apps/webbrowser/www.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/apps/webbrowser/www.c b/apps/webbrowser/www.c
index 0d2dd6ab0..f9624bc49 100644
--- a/apps/webbrowser/www.c
+++ b/apps/webbrowser/www.c
@@ -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. */