fixed heap-buffer-overflow in url_count_inline, fixes #122
authorMichael Göhler <github@nixhub.de>
Wed, 27 Dec 2017 21:48:39 +0000 (22:48 +0100)
committerMichael Göhler <github@nixhub.de>
Wed, 27 Dec 2017 21:48:39 +0000 (22:48 +0100)
src/url.c

index 0e49b49..da21a57 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -165,7 +165,7 @@ int url_count_inline(const wchar_t *line) {
     for (; *i; i++) {
         if (*i == '\\') {
             i++;
     for (; *i; i++) {
         if (*i == '\\') {
             i++;
-        } else if ( *i == '[' && *(i+1) != ']') {
+        } else if ( *i == '[' && *(i+1) && *(i+1) != ']') {
             while (*i && *i != ']') i++;
             i++;
             if (*i == '(' && wcschr(i, ')')) {
             while (*i && *i != ']') i++;
             i++;
             if (*i == '(' && wcschr(i, ')')) {
@@ -185,7 +185,7 @@ int url_len_inline(const wchar_t *value) {
     for (; *i; i++) {
         if (*i == '\\') {
             i++;
     for (; *i; i++) {
         if (*i == '\\') {
             i++;
-        } else if ( *i == '[' && *(i+1) != ']') {
+        } else if ( *i == '[' && *(i+1) && *(i+1) != ']') {
             while (*i && *i != ']') i++;
             i++;
             if (*i == '(' && wcschr(i, ')')) {
             while (*i && *i != ']') i++;
             i++;
             if (*i == '(' && wcschr(i, ')')) {