diff options
-rw-r--r-- | CHANGES | 7 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 108 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 5 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 302 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.c | 11 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 17 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 8 | ||||
-rw-r--r-- | src/GridText.c | 117 | ||||
-rw-r--r-- | src/HTFWriter.c | 4 | ||||
-rw-r--r-- | src/HTInit.c | 4 | ||||
-rw-r--r-- | src/LYExtern.c | 5 | ||||
-rw-r--r-- | src/LYForms.c | 5 | ||||
-rw-r--r-- | src/LYMail.c | 22 | ||||
-rw-r--r-- | src/LYMainLoop.c | 40 | ||||
-rw-r--r-- | src/LYMap.c | 19 | ||||
-rw-r--r-- | src/LYNews.c | 8 | ||||
-rw-r--r-- | src/LYPrettySrc.c | 16 | ||||
-rw-r--r-- | src/LYPrint.c | 10 | ||||
-rw-r--r-- | src/LYReadCFG.c | 8 | ||||
-rw-r--r-- | src/LYStrings.c | 8 | ||||
-rw-r--r-- | src/LYUtils.c | 21 | ||||
-rw-r--r-- | src/UCAuto.c | 8 |
23 files changed, 415 insertions, 342 deletions
diff --git a/CHANGES b/CHANGES index ef8fb8bf..222e946a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,16 +1,17 @@ --- $LynxId: CHANGES,v 1.640 2013/05/03 09:27:54 tom Exp $ +-- $LynxId: CHANGES,v 1.641 2013/05/06 00:18:03 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2013-05-03 (2.8.8dev.16) +2013-05-05 (2.8.8dev.16) * correct handling of backslash in TrimCommand() function introduced in 2.8.6dev.4, used to process the commands for "test=" in mime-types -TD * correct 2.8.3dev.13 check for permissible place to split UTF-8 encoded text, reported by Coverity -TD * make DONT_TRACK_INTERNAL_LINKS logic configurable via lynx.cfg as TRACK_INTERNAL_LINKS; the configure script now sets the default value -TD -* fix issues found by Coverity scan -TD +* fix most issues found by clang 3.2 analyze -TD +* fix most issues found by Coverity scan -TD 2012-11-18 (2.8.8dev.15) * corrected position of highlighting from search/whereis function when using diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index 0c784e3e..441a55e5 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.c,v 1.73 2013/05/02 10:46:12 tom Exp $ + * $LynxId: HTAnchor.c,v 1.74 2013/05/05 19:25:16 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.c * ========================== @@ -319,68 +319,72 @@ HTChildAnchor *HTAnchor_findChildAndLink(HTParentAnchor *parent, /* May not be 0 (ltype == HTInternalLink) ? " (internal link)" : "", NonNull(href))); - if (tag && *tag) { - child = HTAnchor_findNamedChild(parent->parent, tag); + if (parent == 0) { + child = 0; } else { - child = HTAnchor_addChild(parent); - } + if (non_empty(tag)) { + child = HTAnchor_findNamedChild(parent->parent, tag); + } else { + child = HTAnchor_addChild(parent); + } - if (href && *href) { - const char *fragment = NULL; - HTParentAnchor0 *dest; + if (non_empty(href)) { + const char *fragment = NULL; + HTParentAnchor0 *dest; - if (ltype == HTInternalLink && *href == '#') { - dest = parent->parent; - } else { - const char *relative_to = ((parent->inBASE && *href != '#') - ? parent->content_base - : parent->address); - DocAddress parsed_doc; - - parsed_doc.address = HTParse(href, relative_to, - PARSE_ALL_WITHOUT_ANCHOR); - - parsed_doc.post_data = NULL; - parsed_doc.post_content_type = NULL; - if (ltype && parent->post_data && ltype == HTInternalLink) { - /* for internal links, find a destination with the same - post data if the source of the link has post data. - kw - Example: LYNXIMGMAP: */ - parsed_doc.post_data = parent->post_data; - parsed_doc.post_content_type = parent->post_content_type; - } - parsed_doc.bookmark = NULL; - parsed_doc.isHEAD = FALSE; - parsed_doc.safe = FALSE; + if (ltype == HTInternalLink && *href == '#') { + dest = parent->parent; + } else { + const char *relative_to = ((parent->inBASE && *href != '#') + ? parent->content_base + : parent->address); + DocAddress parsed_doc; + + parsed_doc.address = HTParse(href, relative_to, + PARSE_ALL_WITHOUT_ANCHOR); + + parsed_doc.post_data = NULL; + parsed_doc.post_content_type = NULL; + if (ltype && parent->post_data && ltype == HTInternalLink) { + /* for internal links, find a destination with the same + post data if the source of the link has post data. - kw + Example: LYNXIMGMAP: */ + parsed_doc.post_data = parent->post_data; + parsed_doc.post_content_type = parent->post_content_type; + } + parsed_doc.bookmark = NULL; + parsed_doc.isHEAD = FALSE; + parsed_doc.safe = FALSE; - dest = HTAnchor_findAddress_in_adult_table(&parsed_doc); - FREE(parsed_doc.address); - } + dest = HTAnchor_findAddress_in_adult_table(&parsed_doc); + FREE(parsed_doc.address); + } - /* - * [from HTAnchor_findAddress()] - * If the address represents a sub-anchor, we load its parent (above), - * then we create a named child anchor within that parent. - */ - fragment = (*href == '#') ? href + 1 : HTParseAnchor(href); + /* + * [from HTAnchor_findAddress()] + * If the address represents a sub-anchor, we load its parent (above), + * then we create a named child anchor within that parent. + */ + fragment = (*href == '#') ? href + 1 : HTParseAnchor(href); - if (*fragment) - dest = (HTParentAnchor0 *) HTAnchor_findNamedChild(dest, fragment); + if (*fragment) + dest = (HTParentAnchor0 *) HTAnchor_findNamedChild(dest, fragment); - if (tag && *tag) { - if (child->dest) { /* DUPLICATE_ANCHOR_NAME_WORKAROUND - kw */ - CTRACE((tfp, - "*** Duplicate ChildAnchor %p named `%s'", - (void *) child, tag)); - if ((HTAnchor *) dest != child->dest || ltype != child->type) { + if (tag && *tag) { + if (child->dest) { /* DUPLICATE_ANCHOR_NAME_WORKAROUND - kw */ CTRACE((tfp, - ", different dest %p or type, creating unnamed child\n", - (void *) child->dest)); - child = HTAnchor_addChild(parent); + "*** Duplicate ChildAnchor %p named `%s'", + (void *) child, tag)); + if ((HTAnchor *) dest != child->dest || ltype != child->type) { + CTRACE((tfp, + ", different dest %p or type, creating unnamed child\n", + (void *) child->dest)); + child = HTAnchor_addChild(parent); + } } } + HTAnchor_link(child, (HTAnchor *) dest, ltype); } - HTAnchor_link(child, (HTAnchor *) dest, ltype); } return child; } diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index b4b78f52..904ed845 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFTP.c,v 1.120 2013/05/03 23:53:30 tom Exp $ + * $LynxId: HTFTP.c,v 1.121 2013/05/06 00:09:50 tom Exp $ * * File Transfer Protocol (FTP) Client * for a WorldWideWeb browser @@ -2814,7 +2814,8 @@ static void LYListFmtParse(const char *fmtstr, FormatStr(&buf, start, data->filename); PUTS(buf); END(HTML_A); - *buf = '\0'; + if (buf != 0) + *buf = '\0'; if (c != 'A' && data->linkname != 0) { PUTS(" -> "); PUTS(data->linkname); diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index 7731b372..bb75ba4b 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFormat.c,v 1.78 2013/05/01 10:52:13 tom Exp $ + * $LynxId: HTFormat.c,v 1.80 2013/05/05 20:19:02 tom Exp $ * * Manage different file formats HTFormat.c * ============================= @@ -1296,11 +1296,7 @@ static int HTBzFileCopy(BZFILE * bzfp, HTStream *sink) if (HTCheckForInterrupt()) { _HTProgress(TRANSFER_INTERRUPTED); - if (bytes) { - rv = HT_INTERRUPTED; - } else { - rv = -1; - } + rv = HT_INTERRUPTED; break; } } /* next bufferload */ @@ -1450,48 +1446,54 @@ int HTParseFile(HTFormat rep_in, HTStream *stream; HTStreamClass targetClass; int rv; + int result; - if (fp == NULL) - return HT_LOADED; + if (fp == NULL) { + result = HT_LOADED; + } else { + stream = HTStreamStack(rep_in, format_out, sink, anchor); - stream = HTStreamStack(rep_in, format_out, sink, anchor); + if (!stream || !stream->isa) { + char *buffer = 0; - if (!stream) { - char *buffer = 0; + if (LYCancelDownload) { + LYCancelDownload = FALSE; + result = -1; + } else { + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, + HTAtom_name(rep_in), HTAtom_name(format_out)); + CTRACE((tfp, "HTFormat(in HTParseFile): %s\n", buffer)); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + result = rv; + } + } else { - if (LYCancelDownload) { - LYCancelDownload = FALSE; - return -1; - } - HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, - HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE((tfp, "HTFormat(in HTParseFile): %s\n", buffer)); - rv = HTLoadError(sink, 501, buffer); - FREE(buffer); - return rv; - } + /* + * Push the data down the stream + * + * @@ Bug: This decision ought to be made based on "encoding" + * rather than on content-type. @@@ When we handle encoding. The + * current method smells anyway. + */ + targetClass = *(stream->isa); /* Copy pointers to procedures */ + rv = HTFileCopy(fp, stream); + if (rv == -1 || rv == HT_INTERRUPTED) { + (*targetClass._abort) (stream, NULL); + } else { + (*targetClass._free) (stream); + } - /* - * Push the data down the stream - * - * @@ Bug: This decision ought to be made based on "encoding" rather than - * on content-type. @@@ When we handle encoding. The current method - * smells anyway. - */ - targetClass = *(stream->isa); /* Copy pointers to procedures */ - rv = HTFileCopy(fp, stream); - if (rv == -1 || rv == HT_INTERRUPTED) { - (*targetClass._abort) (stream, NULL); - } else { - (*targetClass._free) (stream); + if (rv == -1) { + result = HT_NO_DATA; + } else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) { + result = HT_PARTIAL_CONTENT; + } else { + result = HT_LOADED; + } + } } - - if (rv == -1) - return HT_NO_DATA; - else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) - return HT_PARTIAL_CONTENT; - else - return HT_LOADED; + return result; } #ifdef USE_SOURCE_CACHE @@ -1520,9 +1522,10 @@ int HTParseMem(HTFormat rep_in, HTStream *stream; HTStreamClass targetClass; int rv; + int result; stream = HTStreamStack(rep_in, format_out, sink, anchor); - if (!stream) { + if (!stream || !stream->isa) { char *buffer = 0; HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, @@ -1530,15 +1533,17 @@ int HTParseMem(HTFormat rep_in, CTRACE((tfp, "HTFormat(in HTParseMem): %s\n", buffer)); rv = HTLoadError(sink, 501, buffer); FREE(buffer); - return rv; - } + result = rv; + } else { - /* Push the data down the stream - */ - targetClass = *(stream->isa); - (void) HTMemCopy(chunk, stream); - (*targetClass._free) (stream); - return HT_LOADED; + /* Push the data down the stream + */ + targetClass = *(stream->isa); + (void) HTMemCopy(chunk, stream); + (*targetClass._free) (stream); + result = HT_LOADED; + } + return result; } #endif @@ -1585,47 +1590,52 @@ int HTParseGzFile(HTFormat rep_in, HTStream *stream; HTStreamClass targetClass; int rv; + int result; stream = HTStreamStack(rep_in, format_out, sink, anchor); - if (!stream) { + if (!stream || !stream->isa) { char *buffer = 0; HTCloseGzFile(gzfp); if (LYCancelDownload) { LYCancelDownload = FALSE; - return -1; + result = -1; + } else { + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, + HTAtom_name(rep_in), HTAtom_name(format_out)); + CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer)); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + result = rv; } - HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, - HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer)); - rv = HTLoadError(sink, 501, buffer); - FREE(buffer); - return rv; - } - - /* - * Push the data down the stream - * - * @@ Bug: This decision ought to be made based on "encoding" rather than - * on content-type. @@@ When we handle encoding. The current method - * smells anyway. - */ - targetClass = *(stream->isa); /* Copy pointers to procedures */ - rv = HTGzFileCopy(gzfp, stream); - if (rv == -1 || rv == HT_INTERRUPTED) { - (*targetClass._abort) (stream, NULL); } else { - (*targetClass._free) (stream); - } - HTCloseGzFile(gzfp); - if (rv == -1) - return HT_NO_DATA; - else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) - return HT_PARTIAL_CONTENT; - else - return HT_LOADED; + /* + * Push the data down the stream + * + * @@ Bug: This decision ought to be made based on "encoding" rather than + * on content-type. @@@ When we handle encoding. The current method + * smells anyway. + */ + targetClass = *(stream->isa); /* Copy pointers to procedures */ + rv = HTGzFileCopy(gzfp, stream); + if (rv == -1 || rv == HT_INTERRUPTED) { + (*targetClass._abort) (stream, NULL); + } else { + (*targetClass._free) (stream); + } + + HTCloseGzFile(gzfp); + if (rv == -1) { + result = HT_NO_DATA; + } else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) { + result = HT_PARTIAL_CONTENT; + } else { + result = HT_LOADED; + } + } + return result; } /* HTParseZzFile @@ -1653,47 +1663,52 @@ int HTParseZzFile(HTFormat rep_in, HTStream *stream; HTStreamClass targetClass; int rv; + int result; stream = HTStreamStack(rep_in, format_out, sink, anchor); - if (!stream) { + if (!stream || !stream->isa) { char *buffer = 0; fclose(zzfp); if (LYCancelDownload) { LYCancelDownload = FALSE; - return -1; + result = -1; + } else { + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, + HTAtom_name(rep_in), HTAtom_name(format_out)); + CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer)); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + result = rv; } - HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, - HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer)); - rv = HTLoadError(sink, 501, buffer); - FREE(buffer); - return rv; - } - - /* - * Push the data down the stream - * - * @@ Bug: This decision ought to be made based on "encoding" rather than - * on content-type. @@@ When we handle encoding. The current method - * smells anyway. - */ - targetClass = *(stream->isa); /* Copy pointers to procedures */ - rv = HTZzFileCopy(zzfp, stream); - if (rv == -1 || rv == HT_INTERRUPTED) { - (*targetClass._abort) (stream, NULL); } else { - (*targetClass._free) (stream); - } - fclose(zzfp); - if (rv == -1) - return HT_NO_DATA; - else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) - return HT_PARTIAL_CONTENT; - else - return HT_LOADED; + /* + * Push the data down the stream + * + * @@ Bug: This decision ought to be made based on "encoding" rather than + * on content-type. @@@ When we handle encoding. The current method + * smells anyway. + */ + targetClass = *(stream->isa); /* Copy pointers to procedures */ + rv = HTZzFileCopy(zzfp, stream); + if (rv == -1 || rv == HT_INTERRUPTED) { + (*targetClass._abort) (stream, NULL); + } else { + (*targetClass._free) (stream); + } + + fclose(zzfp); + if (rv == -1) { + result = HT_NO_DATA; + } else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) { + result = HT_PARTIAL_CONTENT; + } else { + result = HT_LOADED; + } + } + return result; } #endif /* USE_ZLIB */ @@ -1729,47 +1744,52 @@ int HTParseBzFile(HTFormat rep_in, HTStream *stream; HTStreamClass targetClass; int rv; + int result; stream = HTStreamStack(rep_in, format_out, sink, anchor); - if (!stream) { + if (!stream || !stream->isa) { char *buffer = 0; HTCloseBzFile(bzfp); if (LYCancelDownload) { LYCancelDownload = FALSE; - return -1; + result = -1; + } else { + HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, + HTAtom_name(rep_in), HTAtom_name(format_out)); + CTRACE((tfp, "HTFormat(in HTParseBzFile): %s\n", buffer)); + rv = HTLoadError(sink, 501, buffer); + FREE(buffer); + result = rv; } - HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O, - HTAtom_name(rep_in), HTAtom_name(format_out)); - CTRACE((tfp, "HTFormat(in HTParseBzFile): %s\n", buffer)); - rv = HTLoadError(sink, 501, buffer); - FREE(buffer); - return rv; - } - - /* - * Push the data down the stream - * - * @@ Bug: This decision ought to be made based on "encoding" rather than - * on content-type. @@@ When we handle encoding. The current method - * smells anyway. - */ - targetClass = *(stream->isa); /* Copy pointers to procedures */ - rv = HTBzFileCopy(bzfp, stream); - if (rv == -1 || rv == HT_INTERRUPTED) { - (*targetClass._abort) (stream, NULL); } else { - (*targetClass._free) (stream); - } - HTCloseBzFile(bzfp); - if (rv == -1) - return HT_NO_DATA; - else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) - return HT_PARTIAL_CONTENT; - else - return HT_LOADED; + /* + * Push the data down the stream + * + * @@ Bug: This decision ought to be made based on "encoding" rather than + * on content-type. @@@ When we handle encoding. The current method + * smells anyway. + */ + targetClass = *(stream->isa); /* Copy pointers to procedures */ + rv = HTBzFileCopy(bzfp, stream); + if (rv == -1 || rv == HT_INTERRUPTED) { + (*targetClass._abort) (stream, NULL); + } else { + (*targetClass._free) (stream); + } + + HTCloseBzFile(bzfp); + if (rv == -1) { + result = HT_NO_DATA; + } else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) { + result = HT_PARTIAL_CONTENT; + } else { + result = HT_LOADED; + } + } + return result; } #endif /* USE_BZLIB */ diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index 0c5934cf..66bdd567 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMIME.c,v 1.86 2013/05/03 20:52:54 tom Exp $ + * $LynxId: HTMIME.c,v 1.87 2013/05/05 20:07:25 tom Exp $ * * MIME Message Parse HTMIME.c * ================== @@ -2447,7 +2447,7 @@ void HTmmdecode(char **target, } if (base64) HTmmdec_base64(&m2buf, mmbuf); - if (quote) + else HTmmdec_quote(&m2buf, mmbuf); for (t = m2buf; *t;) *u++ = *t++; diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index 2a9fae52..dcc9e793 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTString.c,v 1.70 2013/05/03 09:44:08 tom Exp $ + * $LynxId: HTString.c,v 1.71 2013/05/04 12:01:30 tom Exp $ * * Case-independent string comparison HTString.c * @@ -1194,12 +1194,19 @@ void HTEndParam(char **result, */ void HTSABAlloc(bstring **dest, int len) { - if (*dest == 0) + if (*dest == 0) { *dest = typecalloc(bstring); + if (*dest == 0) + outofmem(__FILE__, "HTSABAlloc"); + } + if ((*dest)->len != len) { (*dest)->str = typeRealloc(char, (*dest)->str, len); + if ((*dest)->str == 0) + outofmem(__FILE__, "HTSABAlloc"); + (*dest)->len = len; } } diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index b413491b..7ba0884e 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTTCP.c,v 1.124 2012/11/18 22:24:15 tom Exp $ + * $LynxId: HTTCP.c,v 1.125 2013/05/06 00:07:19 tom Exp $ * * Generic Communication Code HTTCP.c * ========================== @@ -486,7 +486,6 @@ static unsigned read_hostent(int fd, char *buffer, size_t length) while (next_ptr[num_aliases] != 0) { ++num_aliases; } - next_ptr += (num_aliases + 1); next_char += (size_t) (num_aliases + 1) * sizeof(data->h_aliases[0]); } @@ -570,6 +569,7 @@ static size_t fill_rehostent(void **rehostent, if ((result = calloc(need, sizeof(char))) == 0) outofmem(__FILE__, "fill_rehostent"); + *rehostent = result; data = (LYNX_HOSTENT *) (void *) result; @@ -578,6 +578,7 @@ static size_t fill_rehostent(void **rehostent, data->h_length = phost->h_length; p_next_char = result + sizeof(LYNX_HOSTENT); + p_next_charptr = (char **) (void *) p_next_char; if (phost->h_addr_list) p_next_char += (size_t) (num_addrs + 1) * sizeof(phost->h_addr_list[0]); @@ -1472,8 +1473,8 @@ static size_t fill_addrinfo(void **buffer, } CTRACE((tfp, "...fill_addrinfo %d:%lu\n", limit, (unsigned long) need)); - if ((result = calloc(need, sizeof(char))) == 0) - outofmem(__FILE__, "fill_addrinfo"); + if ((result = (LYNX_ADDRINFO *) calloc(1, need)) == 0) + outofmem(__FILE__, "fill_addrinfo"); *buffer = actual = result; heap = ((char *) actual) + ((size_t) limit * sizeof(LYNX_ADDRINFO)); @@ -1485,12 +1486,12 @@ static size_t fill_addrinfo(void **buffer, * packed, uninitialized gaps make it hard to analyse with valgrind. */ /* *INDENT-EQLS* */ - actual->ai_flags = phost->ai_flags; - actual->ai_family = phost->ai_family; + actual->ai_flags = phost->ai_flags; + actual->ai_family = phost->ai_family; actual->ai_socktype = phost->ai_socktype; actual->ai_protocol = phost->ai_protocol; - actual->ai_addrlen = phost->ai_addrlen; - actual->ai_addr = (struct sockaddr *) (void *) heap; + actual->ai_addrlen = phost->ai_addrlen; + actual->ai_addr = (struct sockaddr *) (void *) heap; MemCpy(heap, phost->ai_addr, phost->ai_addrlen); heap += phost->ai_addrlen; diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 1539a8b8..97406851 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTTP.c,v 1.127 2013/01/04 09:42:02 tom Exp $ + * $LynxId: HTTP.c,v 1.128 2013/05/05 19:36:45 tom Exp $ * * HyperText Tranfer Protocol - Client implementation HTTP.c * ========================== @@ -548,8 +548,8 @@ static int HTLoadHTTP(const char *arg, BOOL do_post = FALSE; /* ARE WE posting ? */ const char *METHOD; - char *line_buffer; - char *line_kept_clean; + char *line_buffer = NULL; + char *line_kept_clean = NULL; #ifdef SH_EX /* FIX BUG by kaz@maczuka.hitachi.ibaraki.jp */ int real_length_of_line = 0; @@ -2155,7 +2155,7 @@ static int HTLoadHTTP(const char *arg, HTAlert(line_buffer); HTTP_NETCLOSE(s, handle); status = HT_NO_DATA; - goto done; + goto clean_up; default: /* diff --git a/src/GridText.c b/src/GridText.c index ce96daed..88a4462c 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.258 2013/05/03 20:29:37 tom Exp $ + * $LynxId: GridText.c,v 1.264 2013/05/06 00:06:53 tom Exp $ * * Character grid hypertext object * =============================== @@ -236,13 +236,13 @@ There are 3 functions - POOL_NEW, POOL_FREE, and ALLOC_IN_POOL. #define POOLallocstyles(ptr, n) ptr = ALLOC_IN_POOL(&HTMainText->pool, (unsigned) ((n) * sizeof(pool_data))) #define POOLallocHTLine(ptr, size) ptr = (HTLine*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) LINE_SIZE(size)) -#define POOLallocstring(ptr, len) ptr = (char*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) (len + 1)) +#define POOLallocstring(ptr, len) ptr = (char*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) ((len) + 1)) #define POOLtypecalloc(T, ptr) ptr = (T*) ALLOC_IN_POOL(&HTMainText->pool, (unsigned) sizeof(T)) /**************************************************************************/ /* * Allocates 'n' items in the pool of type 'HTPool' pointed by 'poolptr'. - * Returns a pointer to the "allocated" memory or NULL if fails. + * Returns a pointer to the "allocated" memory if successful. * Updates 'poolptr' if necessary. */ static void *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request) @@ -253,7 +253,7 @@ static void *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request) unsigned j; if (!pool) { - ptr = NULL; + outofmem(__FILE__, "ALLOC_IN_POOL"); } else { n = request; if (n == 0) @@ -270,7 +270,7 @@ static void *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request) HTPool *newpool = (HTPool *) LY_CALLOC((size_t) 1, sizeof(HTPool)); if (!newpool) { - ptr = NULL; + outofmem(__FILE__, "ALLOC_IN_POOL"); } else { newpool->prev = pool; newpool->used = n; @@ -3517,7 +3517,7 @@ static void do_new_line(HText *text, const char *fn, int ln) */ static void blank_lines(HText *text, int newlines) { - if (HText_LastLineEmpty(text, FALSE)) { /* No text on current line */ + if (HText_TrueEmptyLine(text->last_line, text, FALSE)) { /* No text on current line */ HTLine *line = text->last_line->prev; BOOL first = (BOOL) (line == text->last_line); @@ -5758,26 +5758,26 @@ void HText_endAppend(HText *text) /* * Get the first line. */ - line_ptr = FirstHTLine(text); - - /* - * Remove the blank lines at the end of document. - */ - while (text->last_line->data[0] == '\0' && text->Lines > 2) { - HTLine *next_to_the_last_line = text->last_line->prev; - - CTRACE((tfp, "GridText: Removing bottom blank line: `%s'\n", - text->last_line->data)); + if ((line_ptr = FirstHTLine(text)) != 0) { /* - * line_ptr points to the first line. + * Remove the blank lines at the end of document. */ - next_to_the_last_line->next = line_ptr; - line_ptr->prev = next_to_the_last_line; - freeHTLine(text, text->last_line); - text->last_line = next_to_the_last_line; - text->Lines--; - CTRACE((tfp, "GridText: New bottom line: `%s'\n", - text->last_line->data)); + while (text->last_line->data[0] == '\0' && text->Lines > 2) { + HTLine *next_to_the_last_line = text->last_line->prev; + + CTRACE((tfp, "GridText: Removing bottom blank line: `%s'\n", + text->last_line->data)); + /* + * line_ptr points to the first line. + */ + next_to_the_last_line->next = line_ptr; + line_ptr->prev = next_to_the_last_line; + freeHTLine(text, text->last_line); + text->last_line = next_to_the_last_line; + text->Lines--; + CTRACE((tfp, "GridText: New bottom line: `%s'\n", + text->last_line->data)); + } } /* @@ -7949,6 +7949,8 @@ static AnchorIndex **allocAnchorIndex(unsigned *size) *size = countHTLines(); if (*size != 0) { result = typecallocn(AnchorIndex *, *size + 1); + if (result == NULL) + outofmem(__FILE__, "allocAnchorIndex"); for (anchor = HTMainText->first_anchor; anchor != NULL; @@ -8320,7 +8322,7 @@ void print_crawl_to_fd(FILE *fp, char *thelink, } } - if (line == HTMainText->last_line) { + if (!HTMainText || (line == HTMainText->last_line)) { break; } } @@ -8769,6 +8771,20 @@ void HTuncache_current_document(void) } } +/* + * This magic FREE(anchor->UCStages) call + * stolen from HTuncache_current_document() above. + */ +static void magicUncache(void) +{ + if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) { + FREE(HTMainAnchor->UCStages); + } + /* avoid null-reference later */ + if (!HTOutputFormat) + HTOutputFormat = WWW_SOURCE; +} + #ifdef USE_SOURCE_CACHE /* dummy - kw */ @@ -8815,13 +8831,7 @@ BOOLEAN HTreparse_document(void) CTRACE((tfp, "SourceCache: Reparsing file %s\n", HTMainAnchor->source_cache_file)); - /* - * This magic FREE(anchor->UCStages) call - * stolen from HTuncache_current_document() above. - */ - if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) { - FREE(HTMainAnchor->UCStages); - } + magicUncache(); /* * This is more or less copied out of HTLoadFile(), except we don't @@ -8876,13 +8886,7 @@ BOOLEAN HTreparse_document(void) CTRACE((tfp, "SourceCache: Reparsing from memory chunk %p\n", (void *) HTMainAnchor->source_cache_chunk)); - /* - * This magic FREE(anchor->UCStages) call - * stolen from HTuncache_current_document() above. - */ - if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) { - FREE(HTMainAnchor->UCStages); - } + magicUncache(); if (HTMainAnchor->content_type) { format = HTAtom_for(HTMainAnchor->content_type); @@ -9265,10 +9269,11 @@ int HText_getCurrentColumn(HText *text) BOOL IgnoreSpaces = FALSE; if (text) { - column = (text->in_line_1 ? - (int) text->style->indent1st : (int) text->style->leftIndent) - + HText_LastLineSize(text, IgnoreSpaces) - + (int) text->last_line->offset; + column = ((text->in_line_1 + ? (int) text->style->indent1st + : (int) text->style->leftIndent) + + (int) text->last_line->offset + + HText_LastLineSize(text, IgnoreSpaces)); } return column; } @@ -12659,8 +12664,7 @@ static void insert_new_textarea_anchor(TextAnchor **curr_anchor, HTLine **exit_h * YAS (Yet Another Struct), but there are too many structs{} * floating around in here, as it is. IMNSHO.] */ - for (htline = FirstHTLine(HTMainText), i = 0; - anchor->line_num != i; i++) { + for (htline = FirstHTLine(HTMainText), i = 0; anchor->line_num != i; i++) { htline = htline->next; if (htline == HTMainText->last_line) break; @@ -13474,8 +13478,8 @@ int HText_InsertFile(LinkInfo * form_link) FormInfo *f = 0; HTLine *l = 0; - char *fbuf; - char *line; + char *fbuf = 0; + char *line = 0; char *lp; char *cp; int entry_line = form_link->anchor_line_num; @@ -13568,6 +13572,8 @@ int HText_InsertFile(LinkInfo * form_link) if (anchor_ptr == NULL) { CTRACE((tfp, "BUG: could not find anchor for TEXTAREA.\n")); + FREE(line); + FREE(fbuf); return 0; } @@ -13601,20 +13607,21 @@ int HText_InsertFile(LinkInfo * form_link) /* Init all the fields in the new TextAnchor. */ /* [anything "special" needed based on ->show_anchor value ?] */ - a->next = anchor_ptr; - a->number = anchor_ptr->number; + /* *INDENT-EQLS* */ + a->next = anchor_ptr; + a->number = anchor_ptr->number; a->show_number = anchor_ptr->show_number; - a->line_pos = anchor_ptr->line_pos; - a->extent = anchor_ptr->extent; + a->line_pos = anchor_ptr->line_pos; + a->extent = anchor_ptr->extent; a->sgml_offset = SGML_offset(); - a->line_num = anchor_ptr->line_num; + a->line_num = anchor_ptr->line_num; LYCopyHiText(a, anchor_ptr); - a->link_type = anchor_ptr->link_type; + a->link_type = anchor_ptr->link_type; a->input_field = f; a->show_anchor = anchor_ptr->show_anchor; a->inUnderline = anchor_ptr->inUnderline; a->expansion_anch = TRUE; - a->anchor = NULL; + a->anchor = NULL; /* Just the (seemingly) relevant fields in the new FormInfo. */ /* [do we need to do anything "special" based on ->disabled] */ @@ -14092,7 +14099,7 @@ static void move_to_glyph(int YP, */ while ((i <= last_i) && data < end_of_data && (*data != '\0')) { - if (data && hightext && i >= XP && !incurlink) { + if (hightext && i >= XP && !incurlink) { /* * We reached the position of link itself, and hightext is diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 6cdc8edd..d26ed86f 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFWriter.c,v 1.103 2013/05/02 11:05:53 tom Exp $ + * $LynxId: HTFWriter.c,v 1.104 2013/05/04 13:52:11 tom Exp $ * * FILE WRITER HTFWrite.h * =========== @@ -1015,7 +1015,7 @@ HTStream *HTCompressed(HTPresentation *pres, * Deal with any inappropriate invocations of this function, or a download * request, in which case we won't bother to uncompress the file. - FM */ - if (!(anchor && anchor->content_encoding && anchor->content_type)) { + if (!(anchor->content_encoding && anchor->content_type)) { /* * We have no idea what we're dealing with, so treat it as a binary * stream. - FM diff --git a/src/HTInit.c b/src/HTInit.c index 103dcbc2..ecefe149 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTInit.c,v 1.83 2013/05/03 19:47:08 tom Exp $ + * $LynxId: HTInit.c,v 1.84 2013/05/05 19:49:29 tom Exp $ * * Configuration-specific Initialization HTInit.c * ---------------------------------------- @@ -714,7 +714,7 @@ static int BuildCommand(HTChunk *cmd, if ((value = LYGetContentType(name, params)) != 0) { HTChunkPuts(cmd, value); FREE(value); - } else { + } else if (name) { if (!strcmp(name, "charset")) { HTChunkPuts(cmd, "ISO-8859-1"); } else { diff --git a/src/LYExtern.c b/src/LYExtern.c index 3f636f51..f0a7c84d 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYExtern.c,v 1.51 2013/01/04 09:30:03 tom Exp $ + * $LynxId: LYExtern.c,v 1.52 2013/05/04 13:01:06 tom Exp $ * External application support. This feature allows lynx to pass a given URL to an external program. @@ -275,6 +275,9 @@ static char *lookup_external(char *param, if (pass == 0) { actions = typecallocn(char *, length + 1); choices = typecallocn(char *, length + 1); + + if (actions == 0 || choices == 0) + outofmem(__FILE__, "lookup_external"); } else { actions[num_choices] = 0; choices[num_choices] = 0; diff --git a/src/LYForms.c b/src/LYForms.c index 19b15a2f..423d376c 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -1,4 +1,4 @@ -/* $LynxId: LYForms.c,v 1.102 2013/05/01 09:19:14 tom Exp $ */ +/* $LynxId: LYForms.c,v 1.103 2013/05/04 12:58:54 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <HTTP.h> @@ -49,6 +49,9 @@ static char **options_list(OptionType * opt_ptr) if (pass == 0) { len++; result = typecallocn(char *, len); + + if (result == 0) + outofmem(__FILE__, "options_list"); } else { result[len] = 0; } diff --git a/src/LYMail.c b/src/LYMail.c index a366f945..7d4e8e1c 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMail.c,v 1.92 2013/05/03 20:29:37 tom Exp $ + * $LynxId: LYMail.c,v 1.94 2013/05/05 21:41:23 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> @@ -108,7 +108,7 @@ static void extract_field(char **dst, } cp++; } - CTRACE((tfp, "extract_field(%s) = '%s'\n", keyword, NONNULL(*dst))); + CTRACE((tfp, "extract_field(%s) = '%s'\n", keyword, *dst)); } /* @@ -881,16 +881,16 @@ void mailform(const char *mailto_address, FREE(command); LYSleepAlert(); start_curses(); - LYRemoveTemp(my_tmpfile); + (void) LYRemoveTemp(my_tmpfile); if (isPMDF) - LYRemoveTemp(hdrfile); + (void) LYRemoveTemp(hdrfile); #else /* DOS */ LYSendMailFile(address, my_tmpfile, subject, ccaddr, SENDING_FORM_CONTENT); - LYRemoveTemp(my_tmpfile); + (void) LYRemoveTemp(my_tmpfile); #endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ @@ -1095,9 +1095,9 @@ void mailmsg(int cur, LYSystem(command); /* VMS */ FREE(command); FREE(cmd); - LYRemoveTemp(my_tmpfile); + (void) LYRemoveTemp(my_tmpfile); if (isPMDF) { - LYRemoveTemp(hdrfile); + (void) LYRemoveTemp(hdrfile); } #else /* DOS */ LYSendMailFile(address, @@ -1105,7 +1105,7 @@ void mailmsg(int cur, subject, ccaddr, ""); - LYRemoveTemp(my_tmpfile); + (void) LYRemoveTemp(my_tmpfile); #endif /* USE_VMS_MAILER */ #endif /* CAN_PIPE_TO_MAILER */ @@ -1723,7 +1723,7 @@ void reply_by_mail(char *mail_address, the_subject, ccaddr, SENDING_COMMENT); - LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ + (void) LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ #endif /* CAN_PIPE_TO_MAILER */ LYCloseInput(fd); /* Close the tmpfile. */ } @@ -1745,11 +1745,11 @@ void reply_by_mail(char *mail_address, #if USE_VMS_MAILER while (LYRemoveTemp(my_tmpfile) == 0) ; /* Delete the tmpfile(s). */ if (isPMDF) { - LYRemoveTemp(hdrfile); /* Delete the hdrfile. */ + (void) LYRemoveTemp(hdrfile); /* Delete the hdrfile. */ } #else FREE(header); - LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ + (void) LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ #endif /* VMS */ FREE(from_address); diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 481685b8..5d66b5cc 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.216 2013/05/03 20:29:37 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.217 2013/05/05 20:36:20 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -1530,19 +1530,17 @@ static FormInfo *MakeFormAction(FormInfo * given, BOOLEAN submit) outofmem(__FILE__, "MakeFormAction"); *result = *given; - if (result != 0) { - if (submit) { - if (result->submit_action == 0) { - PerFormInfo *pfi = HText_PerFormInfo(result->number); + if (submit) { + if (result->submit_action == 0) { + PerFormInfo *pfi = HText_PerFormInfo(result->number); - *result = pfi->data; - } - result->type = F_SUBMIT_TYPE; - } else { - result->type = F_RESET_TYPE; + *result = pfi->data; } - result->number = given->number; + result->type = F_SUBMIT_TYPE; + } else { + result->type = F_RESET_TYPE; } + result->number = given->number; } return result; } @@ -3670,17 +3668,17 @@ static BOOLEAN handle_LYK_JUMP(int c, if (!LYTrimStartfile(ret)) { LYRemoveBlanks((*user_input)->str); } - if (!check_JUMP_param(&ret)) - return FALSE; - set_address(&newdoc, ret); - StrAllocCopy(lynxjumpfile, ret); - LYFreePostData(&newdoc); - FREE(newdoc.bookmark); - newdoc.isHEAD = FALSE; - newdoc.safe = FALSE; - newdoc.internal_link = FALSE; + if (check_JUMP_param(&ret)) { + set_address(&newdoc, ret); + StrAllocCopy(lynxjumpfile, ret); + LYFreePostData(&newdoc); + FREE(newdoc.bookmark); + newdoc.isHEAD = FALSE; + newdoc.safe = FALSE; + newdoc.internal_link = FALSE; + LYUserSpecifiedURL = TRUE; + } FREE(ret); - LYUserSpecifiedURL = TRUE; } else { LYJumpFileURL = FALSE; } diff --git a/src/LYMap.c b/src/LYMap.c index f15e68a2..3ec8cf78 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMap.c,v 1.45 2013/04/30 23:16:59 tom Exp $ + * $LynxId: LYMap.c,v 1.47 2013/05/06 00:53:46 tom Exp $ * Lynx Client-side Image MAP Support LYMap.c * ================================== * @@ -273,7 +273,7 @@ BOOL LYAddMapElement(char *map, else StrAllocCopy(tmp->title, address); if (track_internal_links) - tmp->intern_flag = intern_flag; + tmp->intern_flag = (BOOLEAN) intern_flag; HTList_appendObject(theMap->elements, tmp); CTRACE((tfp, @@ -370,15 +370,20 @@ static HTList *get_the_list(DocAddress *wwwdoc, HTParentAnchor *anchor, HTParentAnchor **punderlying) { - if (anchor && anchor->post_data) { + HTList *result; + + if (anchor->post_data) { fill_DocAddress(wwwdoc, address, anchor, punderlying); - if (non_empty(punderlying)) - return (*punderlying)->imaps; - return anchor->imaps; + if (non_empty(punderlying)) { + result = (*punderlying)->imaps; + } else { + result = anchor->imaps; + } } else { fill_DocAddress(wwwdoc, address, NULL, punderlying); - return LynxMaps; + result = LynxMaps; } + return result; } /* LYLoadIMGmap - F.Macrides (macrides@sci.wfeb.edu) diff --git a/src/LYNews.c b/src/LYNews.c index 630925d0..f226da4a 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYNews.c,v 1.58 2013/05/02 10:39:50 tom Exp $ + * $LynxId: LYNews.c,v 1.59 2013/05/04 13:15:30 tom Exp $ */ #include <HTUtils.h> #ifndef DISABLE_NEWS @@ -450,7 +450,7 @@ char *LYNewsPost(char *newsgroups, LYCloseTempFP(fc); StrAllocCopy(postfile, CJKfile); LYCloseInput(fd); - LYRemoveTemp(my_tempfile); + (void) LYRemoveTemp(my_tempfile); strcpy(my_tempfile, CJKfile); CJKfile[0] = '\0'; } else { @@ -482,8 +482,8 @@ char *LYNewsPost(char *newsgroups, #endif /* !VMS */ term_message = FALSE; if (!postfile) - LYRemoveTemp(my_tempfile); - LYRemoveTemp(CJKfile); + (void) LYRemoveTemp(my_tempfile); + (void) LYRemoveTemp(CJKfile); FREE(NewsGroups); FREE(References); diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c index d85a93f0..38e342d8 100644 --- a/src/LYPrettySrc.c +++ b/src/LYPrettySrc.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrettySrc.c,v 1.25 2010/10/27 00:15:12 tom Exp $ + * $LynxId: LYPrettySrc.c,v 1.28 2013/05/06 00:53:30 tom Exp $ * * HTML source syntax highlighting * by Vlad Harchev <hvv@hippo.ru> @@ -109,10 +109,21 @@ static void append_close_tag(char *tagname, } subj = typecalloc(HT_tagspec); + if (subj == 0) + outofmem(__FILE__, "append_close_tag"); + subj->element = (HTMLElement) idx; + subj->present = typecallocn(BOOL, (unsigned) nattr); + + if (subj->present == 0) + outofmem(__FILE__, "append_close_tag"); + subj->value = typecallocn(char *, (unsigned) nattr); + if (subj->value == 0) + outofmem(__FILE__, "append_close_tag"); + subj->start = FALSE; #ifdef USE_COLOR_STYLE subj->class_name = NULL; @@ -399,6 +410,7 @@ void HTMLSRC_init_caches(int dont_exit) int i; char *p; char buf[1000]; + static char empty[] = ""; CTRACE2(TRACE_CFG, (tfp, "HTMLSRC_init_caches(%d tagspecs)\n", HTL_num_lexemes)); for (i = 0; i < HTL_num_lexemes; ++i) { @@ -420,7 +432,7 @@ void HTMLSRC_init_caches(int dont_exit) TRUE) && !dont_exit) { failed_init("1st", i); } - if (!html_src_parse_tagspec(p ? p + 1 : NULL, + if (!html_src_parse_tagspec(p ? p + 1 : empty, (HTlexeme) i, FALSE, FALSE) && !dont_exit) { diff --git a/src/LYPrint.c b/src/LYPrint.c index f1e8675e..b4020815 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYPrint.c,v 1.97 2012/08/03 17:39:19 tom Exp $ + * $LynxId: LYPrint.c,v 1.98 2013/05/04 13:15:47 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -669,8 +669,8 @@ static void send_file_to_mail(DocInfo *newdoc, SetOutputMode(O_BINARY); if (isPMDF) - LYRemoveTemp(hdrfile); - LYRemoveTemp(my_temp); + (void) LYRemoveTemp(hdrfile); + (void) LYRemoveTemp(my_temp); #else /* !VMS (Unix or DOS) */ #if CAN_PIPE_TO_MAILER @@ -783,7 +783,7 @@ static void send_file_to_mail(DocInfo *newdoc, subject, "", ""); - LYRemoveTemp(my_temp); /* Delete the tmpfile. */ + (void) LYRemoveTemp(my_temp); /* Delete the tmpfile. */ #endif /* CAN_PIPE_TO_MAILER */ #endif /* USE_VMS_MAILER */ @@ -927,7 +927,7 @@ static void send_file_to_printer(DocInfo *newdoc, LYSystem(the_command); FREE(the_command); - LYRemoveTemp(my_temp); + (void) LYRemoveTemp(my_temp); /* * Remove the various LYNX_PRINT_xxxx logicals. - KED diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 34333bc1..3e048117 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.171 2013/04/30 09:52:44 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.172 2013/05/04 12:24:06 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -1969,9 +1969,13 @@ BOOL LYSetConfigValue(const char *name, #ifdef VMS Define_VMSLogical(temp_name, value); #else - if (q->str_value == 0) + if (q->str_value == 0) { q->str_value = typecalloc(char *); + if (q->str_value == 0) + outofmem(__FILE__, "LYSetConfigValue"); + } + HTSprintf0(q->str_value, "%s=%s", temp_name, value); putenv(*(q->str_value)); #endif diff --git a/src/LYStrings.c b/src/LYStrings.c index 3d653e42..0dfa664f 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.212 2013/05/03 20:29:37 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.213 2013/05/04 12:21:36 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -2951,8 +2951,14 @@ void LYSetupEdit(EDREC * edit, char *old_value, size_t buffer_limit, int display StrLen = strlen(old_value); Buf = typecallocn(char, MaxLen + 1); + if (Buf == 0) + outofmem(__FILE__, "LYSetupEdit"); + LYStrNCpy(Buf, old_value, buffer_limit); Offs2Col = typecallocn(int, MaxLen + 1); + + if (Offs2Col == 0) + outofmem(__FILE__, "LYSetupEdit"); } #ifdef SUPPORT_MULTIBYTE_EDIT diff --git a/src/LYUtils.c b/src/LYUtils.c index 51fd6526..011b15db 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.238 2013/05/03 20:21:20 tom Exp $ + * $LynxId: LYUtils.c,v 1.239 2013/05/05 21:26:26 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -5466,7 +5466,7 @@ static char *FindLeadingTilde(char *pathname, int embedded) */ char *LYAbsOrHomePath(char **fname) { - if (!LYisAbsPath(*fname)) { + if (*fname && !LYisAbsPath(*fname)) { if (LYIsTilde((*fname)[0])) { LYTildeExpand(fname, FALSE); } else { @@ -5768,20 +5768,21 @@ int remove(char *name) static BOOL IsOurSymlink(const char *name) { BOOL result = FALSE; - int size = LY_MAXPATH; - int used; + size_t size = LY_MAXPATH; + size_t used; char *buffer = typeMallocn(char, (unsigned) size); + char *check; if (buffer != 0) { - while ((used = (int) readlink(name, buffer, (size_t) (size - 1))) == size - - 1) { - buffer = typeRealloc(char, buffer, (unsigned) (size *= 2)); + while ((used = (size_t) readlink(name, buffer, (size - 1))) == size - 1) { + check = typeRealloc(char, buffer, (unsigned) (size *= 2)); - if (buffer == 0) + if (check == 0) break; + buffer = check; } if (buffer != 0) { - if (used > 0) { + if ((int) used > 0) { buffer[used] = '\0'; } else { FREE(buffer); @@ -6822,7 +6823,7 @@ void LYLocalFileToURL(char **target, LYAddHtmlSep(target); StrAllocCat(*target, temp); } - if (!LYIsHtmlSep(*leaf)) + if (leaf && !LYIsHtmlSep(*leaf)) LYAddHtmlSep(target); StrAllocCat(*target, leaf); } diff --git a/src/UCAuto.c b/src/UCAuto.c index 4fc0927c..d7f168e1 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCAuto.c,v 1.50 2013/05/03 20:30:33 tom Exp $ + * $LynxId: UCAuto.c,v 1.51 2013/05/04 13:14:39 tom Exp $ * * This file contains code for changing the Linux console mode. * Currently some names for font files are hardwired in here. @@ -289,11 +289,11 @@ void UCChangeTerminalCodepage(int newcs, } if (newcs < 0 && p == 0) { if (old_font) { - LYRemoveTemp(old_font); + (void) LYRemoveTemp(old_font); FREE(old_font); } if (old_umap) { - LYRemoveTemp(old_umap); + (void) LYRemoveTemp(old_umap); FREE(old_umap); } if (status == 0) { @@ -344,7 +344,7 @@ void UCChangeTerminalCodepage(int newcs, old_umap = typeRealloc(char, old_umap, nlen); } else { if (fp1) - LYRemoveTemp(old_font); + (void) LYRemoveTemp(old_font); FREE(old_font); FREE(old_umap); } |