Uncovered by Pawel Worach using clang static analysis tool.
Fixes:
* several NULL pointer dereferences
* several unused variable return saves
* a parentheses typo
#include "config.h"
#include "util.h"
-/* Convert ISO-LATIN-1 to UTF-8
- */
+/** Convert ISO-LATIN-1 to UTF-8 */
char *
latin1_to_utf8(char *out, size_t size, const char *in)
{
- unsigned char *p;
- for (p = (unsigned char *)out; *in && size > 2; in++) {
+ unsigned char *p = (unsigned char *)out;
+ for (; *in && size > 2; in++) {
unsigned char ch = (unsigned char)*in;
if (ch < 0x80) {
*p++ = ch;
size--;
}
}
- *p++ = '\0';
+ *p = '\0';
if (*in)
return NULL;
return out;
}
-
-
if (tt == saved_tt) {
struct squid_radix_node *xx = x;
/* link in at head of list */
- (tt = treenodes)->rn_dupedkey = t;
+ tt = treenodes;
+ tt->rn_dupedkey = t;
tt->rn_flags = t->rn_flags;
tt->rn_p = x = t->rn_p;
if (x->rn_l == t)
saved_tt = tt;
x = xx;
} else {
- (tt = treenodes)->rn_dupedkey = t->rn_dupedkey;
+ tt = treenodes;
+ tt->rn_dupedkey = t->rn_dupedkey;
t->rn_dupedkey = tt;
}
#ifdef RN_DEBUG
if (enabled || verbose_output) {
for (line = entry->nocomment; line != NULL; line = line->next) {
+ if (!line->data)
+ continue;
if (!enabled && line->data[0] != '#')
fprintf(fp, "#%s\n", line->data);
else
-/*
+1158/*
* DEBUG: section 0 CGI Cache Manager
* AUTHOR: Duane Wessels
*
xfree(buf_copy);
/* record ends */
- l += snprintf(html + l, sizeof(html) - l, "</tr>\n");
+ snprintf(html + l, sizeof(html) - l, "</tr>\n");
next_is_header = is_header && strstr(buf, "\t\t");
table_line_num++;
return html;
if ( !S.IsAnyAddr() ) {
(void) 0;
- } else if ( S = req->hostname)
+ } else if ((S = req->hostname))
(void) 0;
else {
snprintf(buf, 1024, "Unknown host: %s\n", req->hostname);
assert(stringLength < sizeof(buf));
- stringLength += snprintf(&buf[stringLength], sizeof(buf) - stringLength,
- "Proxy-Authorization: Basic %s\r\n", str64);
+ snprintf(&buf[stringLength], sizeof(buf) - stringLength, "Proxy-Authorization: Basic %s\r\n", str64);
return buf;
}