From 34af5c2465d962f4b00562a31bece4fc2f9d730e Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Sat, 25 Jul 2015 14:49:57 +0200 Subject: use pclose for pipe --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index 605fc78..0b13a99 100644 --- a/file.c +++ b/file.c @@ -8540,7 +8540,7 @@ lessopen_stream(char *path) } c = getc(fp); if (c == EOF) { - fclose(fp); + pclose(fp); return NULL; } ungetc(c, fp); -- cgit v1.2.3 From 1970c42320d16c2791613e41e00775452dfb9aab Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Sat, 25 Jul 2015 14:50:04 +0200 Subject: Initialise hidden_input to NULL This prevents a possible use of garbage value on line 3017. --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index 0b13a99..df865a0 100644 --- a/file.c +++ b/file.c @@ -2713,7 +2713,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, Str line = obuf->line, pass = NULL; char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL, *hidden_under = NULL, *hidden_italic = NULL, *hidden_strike = NULL, - *hidden_ins = NULL, *hidden_input, *hidden = NULL; + *hidden_ins = NULL, *hidden_input = NULL, *hidden = NULL; #ifdef DEBUG if (w3m_debug) { -- cgit v1.2.3 From f3c14dfe6b5a845470212c3e36dbb66821fe8d8c Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Sat, 25 Jul 2015 14:53:22 +0200 Subject: Avoid passing null to strlen --- rc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.c b/rc.c index a839bb3..b85d50b 100644 --- a/rc.c +++ b/rc.c @@ -837,7 +837,7 @@ void show_params(FILE * fp) { int i, j, l; - char *t = NULL; + const char *t = ""; char *cmt; #ifdef USE_M17N -- cgit v1.2.3 From 913628e0d68564ab0f3f1e1e51902af93454effc Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Sat, 25 Jul 2015 15:03:02 +0200 Subject: Close temp file if pipe open fails --- local.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/local.c b/local.c index 9428319..2728627 100644 --- a/local.c +++ b/local.c @@ -386,9 +386,11 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer) cgi_basename = mybasename(file); pid = open_pipe_rw(&fr, NULL); /* Don't invoke gc after here, or the program might crash in some platforms */ - if (pid < 0) + if (pid < 0) { + if (fw) + fclose(fw); return NULL; - else if (pid) { + } else if (pid) { if (fw) fclose(fw); return fr; -- cgit v1.2.3 From 91405c0d06e25e160627d915b6e9747540585f09 Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Sat, 25 Jul 2015 15:14:15 +0200 Subject: Strnew_charp and co do not modify the char* input --- Str.c | 16 ++++++++-------- Str.h | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Str.c b/Str.c index eff82a4..f819dbf 100644 --- a/Str.c +++ b/Str.c @@ -56,7 +56,7 @@ Strnew_size(int n) } Str -Strnew_charp(char *p) +Strnew_charp(const char *p) { Str x; int n; @@ -73,7 +73,7 @@ Strnew_charp(char *p) } Str -Strnew_m_charp(char *p, ...) +Strnew_m_charp(const char *p, ...) { va_list ap; Str r = Strnew(); @@ -87,7 +87,7 @@ Strnew_m_charp(char *p, ...) } Str -Strnew_charp_n(char *p, int n) +Strnew_charp_n(const char *p, int n) { Str x; @@ -140,7 +140,7 @@ Strcopy(Str x, Str y) } void -Strcopy_charp(Str x, char *y) +Strcopy_charp(Str x, const char *y) { int len; @@ -160,7 +160,7 @@ Strcopy_charp(Str x, char *y) } void -Strcopy_charp_n(Str x, char *y, int n) +Strcopy_charp_n(Str x, const char *y, int n) { int len = n; @@ -180,7 +180,7 @@ Strcopy_charp_n(Str x, char *y, int n) } void -Strcat_charp_n(Str x, char *y, int n) +Strcat_charp_n(Str x, const char *y, int n) { int newlen; @@ -209,7 +209,7 @@ Strcat(Str x, Str y) } void -Strcat_charp(Str x, char *y) +Strcat_charp(Str x, const char *y) { if (y == NULL) return; @@ -301,7 +301,7 @@ Strinsert_char(Str s, int pos, char c) } void -Strinsert_charp(Str s, int pos, char *p) +Strinsert_charp(Str s, int pos, const char *p) { STR_LENGTH_CHECK(s); while (*p) diff --git a/Str.h b/Str.h index f345c74..248815d 100644 --- a/Str.h +++ b/Str.h @@ -30,22 +30,22 @@ typedef struct _Str { Str Strnew(void); Str Strnew_size(int); -Str Strnew_charp(char *); -Str Strnew_charp_n(char *, int); -Str Strnew_m_charp(char *, ...); +Str Strnew_charp(const char *); +Str Strnew_charp_n(const char *, int); +Str Strnew_m_charp(const char *, ...); Str Strdup(Str); void Strclear(Str); void Strfree(Str); void Strcopy(Str, Str); -void Strcopy_charp(Str, char *); -void Strcopy_charp_n(Str, char *, int); -void Strcat_charp_n(Str, char *, int); +void Strcopy_charp(Str, const char *); +void Strcopy_charp_n(Str, const char *, int); +void Strcat_charp_n(Str, const char *, int); void Strcat(Str, Str); -void Strcat_charp(Str, char *); +void Strcat_charp(Str, const char *); void Strcat_m_charp(Str, ...); Str Strsubstr(Str, int, int); void Strinsert_char(Str, int, char); -void Strinsert_charp(Str, int, char *); +void Strinsert_charp(Str, int, const char *); void Strdelete(Str, int, int); void Strtruncate(Str, int); void Strlower(Str); -- cgit v1.2.3