fix possible NULL pointer access, thanks to the CLANG static analyser.
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 24 May 2011 21:55:08 +0000 (21:55 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 24 May 2011 21:55:08 +0000 (21:55 +0000)
webcit/html2html.c

index 4185b1fedae980fc58db27c7feec74ddb6c1ec24..b91218b215d99cf8e06d2df7d3d4789da453accc 100644 (file)
@@ -529,17 +529,19 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                         * so we don't turn things that look like URL's into
                         * links, when they're already links - or image sources.
                         */
-                       if ((ptr > msg) && (*(ptr-1) == '<')) {
+                       if ((ptr != NULL) && (ptr > msg) && (*(ptr-1) == '<')) {
                                ++brak;
                        }
-                       if ((ptr > msg) && (*(ptr-1) == '>')) {
+                       if ((ptr != NULL) && (ptr > msg) && (*(ptr-1) == '>')) {
                                --brak;
                                if ((scriptlevel == 0) && (script_start_pos >= 0)) {
                                        StrBufCutRight(converted_msg, StrLength(converted_msg) - script_start_pos);
                                        script_start_pos = (-1);
                                }
                        }
-                       if (!strncasecmp(ptr, "</A>", 3)) --alevel;
+                       if ((ptr != NULL) && 
+                           !strncasecmp(ptr, "</A>", 3))
+                               --alevel;
                }
        }