From 6c6a2cbced21ceec2fac08fba1ad271a77f9dbc2 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Mon, 5 Dec 2016 00:31:34 +0900 Subject: Prevent negative array index in getMetaRefreshParam() Bug-Debian: https://github.com/tats/w3m/issues/63 --- file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index a87737a..b9ccd86 100644 --- a/file.c +++ b/file.c @@ -4378,8 +4378,9 @@ getMetaRefreshParam(char *q, Str *refresh_uri) r++; s_tmp = Strnew_charp_n(q, r - q); - if (s_tmp->ptr[s_tmp->length - 1] == '\"' /* " */ - || s_tmp->ptr[s_tmp->length - 1] == '\'') { /* ' */ + if (s_tmp->length > 0 && + (s_tmp->ptr[s_tmp->length - 1] == '\"' || /* " */ + s_tmp->ptr[s_tmp->length - 1] == '\'')) { /* ' */ s_tmp->length--; s_tmp->ptr[s_tmp->length] = '\0'; } -- cgit v1.2.3