Skip to content

Commit cb4cdee

Browse files
committed
Fix some minor Coverity warnings.
1 parent a3ea541 commit cb4cdee

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changes in HTMLDOC v1.9.16
22

33
- Updated the GUI interface for current display fonts.
4+
- Fixed some minor Coverity warnings.
45

56

67
# Changes in HTMLDOC v1.9.15

htmldoc/http.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* HTTP routines for HTMLDOC.
33
*
4-
* Copyright © 2020-2021 by Michael R Sweet
4+
* Copyright © 2020-2022 by Michael R Sweet
55
* Copyright © 2007-2019 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77
*
@@ -2421,6 +2421,7 @@ httpReconnect2(http_t *http, /* I - HTTP connection */
24212421
if (_httpTLSStart(http) != 0)
24222422
{
24232423
httpAddrClose(NULL, http->fd);
2424+
http->fd = -1;
24242425

24252426
return (-1);
24262427
}
@@ -3555,7 +3556,9 @@ http_add_field(http_t *http, /* I - HTTP connection */
35553556
const char *value, /* I - Value string */
35563557
int append) /* I - Append value? */
35573558
{
3558-
char temp[1024]; /* Temporary value string */
3559+
char temp[1024], /* Temporary value string */
3560+
combined[HTTP_MAX_VALUE];
3561+
/* Combined value string */
35593562
size_t fieldlen, /* Length of existing value */
35603563
valuelen, /* Length of value string */
35613564
total; /* Total length of string */
@@ -3630,8 +3633,6 @@ http_add_field(http_t *http, /* I - HTTP connection */
36303633

36313634
if (total < HTTP_MAX_VALUE && field < HTTP_FIELD_ACCEPT_ENCODING)
36323635
{
3633-
char combined[HTTP_MAX_VALUE]; /* Combined value string */
3634-
36353636
/*
36363637
* Copy short values to legacy char arrays (maintained for binary
36373638
* compatibility with CUPS 1.2.x and earlier applications...)
@@ -3652,21 +3653,21 @@ http_add_field(http_t *http, /* I - HTTP connection */
36523653
* Expand the field value...
36533654
*/
36543655

3655-
char *combined; /* New value string */
3656+
char *mcombined; /* New value string */
36563657

36573658
if (http->fields[field] == http->_fields[field])
36583659
{
3659-
if ((combined = malloc(total + 1)) != NULL)
3660+
if ((mcombined = malloc(total + 1)) != NULL)
36603661
{
3661-
http->fields[field] = combined;
3662-
snprintf(combined, total + 1, "%s, %s", http->_fields[field], value);
3662+
http->fields[field] = mcombined;
3663+
snprintf(mcombined, total + 1, "%s, %s", http->_fields[field], value);
36633664
}
36643665
}
3665-
else if ((combined = realloc(http->fields[field], total + 1)) != NULL)
3666+
else if ((mcombined = realloc(http->fields[field], total + 1)) != NULL)
36663667
{
3667-
http->fields[field] = combined;
3668-
strlcat(combined, ", ", total + 1);
3669-
strlcat(combined, value, total + 1);
3668+
http->fields[field] = mcombined;
3669+
strlcat(mcombined, ", ", total + 1);
3670+
strlcat(mcombined, value, total + 1);
36703671
}
36713672
}
36723673
else
@@ -4613,6 +4614,7 @@ http_tls_upgrade(http_t *http) /* I - HTTP connection */
46134614
* Restore the HTTP request data...
46144615
*/
46154616

4617+
httpClearFields(http);
46164618
memcpy(http->_fields, myhttp._fields, sizeof(http->_fields));
46174619
memcpy(http->fields, myhttp.fields, sizeof(http->fields));
46184620

htmldoc/image.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ gif_read_lzw(FILE *fp, /* I - File to read from */
481481

482482
while (code >= clear_code)
483483
{
484-
if (sp >= (stack + sizeof(stack)))
484+
if (sp >= (stack + sizeof(stack) / sizeof(stack[0])))
485485
return (255);
486486

487487
*sp++ = table[1][code];
@@ -492,7 +492,7 @@ gif_read_lzw(FILE *fp, /* I - File to read from */
492492
code = table[0][code];
493493
}
494494

495-
if (sp >= (stack + sizeof(stack)))
495+
if (sp >= (stack + sizeof(stack) / sizeof(stack[0])))
496496
return (255);
497497

498498
*sp++ = firstcode = table[1][code];

htmldoc/ps-pdf.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,8 @@ pdf_write_document(uchar *author, // I - Author of document
22792279
if (images[i] == hfimage[hfi])
22802280
break;
22812281

2282+
memset(&temp, 0, sizeof(temp)); // For Coverity, not explicitly necessary
2283+
22822284
if (images[i]->use > 1 || images[i]->mask ||
22832285
(images[i]->width * images[i]->height * images[i]->depth) > 65536 ||
22842286
images[i] == background_image ||

0 commit comments

Comments
 (0)