diff options
author | Lars Hjemli | 2006-12-28 01:54:43 +0100 |
---|---|---|
committer | Lars Hjemli | 2006-12-28 01:54:43 +0100 |
commit | 27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6 (patch) | |
tree | 041158893604fa4127bc0df31a2c22f8d48b852f | |
parent | c43f1246cb759eb811ab0ebef0613b86dda99581 (diff) | |
download | cgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.tar.gz cgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.tar.bz2 cgit-27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6.zip |
Test for NULL-pointers in html_txt() and friends
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | html.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -45,7 +45,7 @@ void htmlf(const char *format, ...) | |||
45 | void html_txt(char *txt) | 45 | void html_txt(char *txt) |
46 | { | 46 | { |
47 | char *t = txt; | 47 | char *t = txt; |
48 | while(*t){ | 48 | while(t && *t){ |
49 | int c = *t; | 49 | int c = *t; |
50 | if (c=='<' || c=='>' || c=='&') { | 50 | if (c=='<' || c=='>' || c=='&') { |
51 | *t = '\0'; | 51 | *t = '\0'; |
@@ -68,7 +68,7 @@ void html_txt(char *txt) | |||
68 | void html_ntxt(int len, char *txt) | 68 | void html_ntxt(int len, char *txt) |
69 | { | 69 | { |
70 | char *t = txt; | 70 | char *t = txt; |
71 | while(*t && len--){ | 71 | while(t && *t && len--){ |
72 | int c = *t; | 72 | int c = *t; |
73 | if (c=='<' || c=='>' || c=='&') { | 73 | if (c=='<' || c=='>' || c=='&') { |
74 | *t = '\0'; | 74 | *t = '\0'; |
@@ -97,7 +97,7 @@ void html_ntxt(int len, char *txt) | |||
97 | void html_attr(char *txt) | 97 | void html_attr(char *txt) |
98 | { | 98 | { |
99 | char *t = txt; | 99 | char *t = txt; |
100 | while(*t){ | 100 | while(t && *t){ |
101 | int c = *t; | 101 | int c = *t; |
102 | if (c=='<' || c=='>' || c=='\'') { | 102 | if (c=='<' || c=='>' || c=='\'') { |
103 | *t = '\0'; | 103 | *t = '\0'; |
@@ -155,4 +155,3 @@ void html_filemode(unsigned short mode) | |||
155 | html_fileperm(mode >> 3); | 155 | html_fileperm(mode >> 3); |
156 | html_fileperm(mode); | 156 | html_fileperm(mode); |
157 | } | 157 | } |
158 | |||