From 6beef589e32d874e5d961e7e6f7b2a68c56538bd Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Wed, 9 Jan 2013 14:37:57 -0800 Subject: Make source cleah with cppcheck, except for mpc and sasl --- src/common/dcc.c | 3 +++ src/common/outbound.c | 2 +- src/common/server.c | 1 + src/common/util.c | 11 ++++++++++- src/fe-gtk/fkeys.c | 1 + src/fe-gtk/maingui.c | 3 ++- src/fe-text/fe-text.c | 2 +- 7 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/common/dcc.c b/src/common/dcc.c index d404b617..9014296e 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -322,6 +322,7 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr) memcpy (&addr->sin_addr, h->h_addr, 4); memcpy (&cache_addr, h->h_addr, 4); cache_host = strdup (host); + /* cppcheck-suppress memleak */ return TRUE; } @@ -788,6 +789,7 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc) dcc_send_ack (dcc); dcc_close (dcc, STAT_DONE, FALSE); dcc_calc_average_cps (dcc); /* this must be done _after_ dcc_close, or dcc_remove_from_sum will see the wrong value in dcc->cps */ + /* cppcheck-suppress deallocuse */ sprintf (buf, "%d", dcc->cps); EMIT_SIGNAL (XP_TE_DCCRECVCOMP, dcc->serv->front_session, dcc->file, dcc->destfile, dcc->nick, buf, 0); @@ -1533,6 +1535,7 @@ dcc_handle_new_ack (struct DCC *dcc) dcc->ack = dcc->size; /* force 100% ack for >4 GB */ dcc_close (dcc, STAT_DONE, FALSE); dcc_calc_average_cps (dcc); /* this must be done _after_ dcc_close, or dcc_remove_from_sum will see the wrong value in dcc->cps */ + /* cppcheck-suppress deallocuse */ sprintf (buf, "%d", dcc->cps); EMIT_SIGNAL (XP_TE_DCCSENDCOMP, dcc->serv->front_session, file_part (dcc->file), dcc->nick, buf, NULL, 0); diff --git a/src/common/outbound.c b/src/common/outbound.c index a8a65d6a..f8f73dd6 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -1866,7 +1866,6 @@ cmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[]) /* not reached unless error */ /*printf("exec error\n");*/ fflush (stdout); - fflush (stdin); _exit (0); } if (pid == -1) @@ -1876,6 +1875,7 @@ cmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[]) PrintText (sess, "Error in fork(2)\n"); close(fds[0]); close(fds[1]); + free (s); } else { /* Parent path */ diff --git a/src/common/server.c b/src/common/server.c index 1fd04422..6ddaa18d 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -1678,6 +1678,7 @@ xit: #endif return 0; + /* cppcheck-suppress memleak */ } static void diff --git a/src/common/util.c b/src/common/util.c index 55cb530a..38537402 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1319,8 +1319,17 @@ int my_poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) { if (*argv[argc]) { buf++, argc++; if (argc == argvAlloced) { + char *temp[]; argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA; - argv = realloc(argv, sizeof(*argv) * argvAlloced); + temp = realloc(argv, sizeof(*argv) * argvAlloced); + if (temp) + argv = temp; + else + { + free(argv); + free(bufStart); + return 1; + } } argv[argc] = buf; } diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index 99d244ea..3a937e1a 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -1153,6 +1153,7 @@ key_load_kbs (char *filename) get_xdir ()); fe_message (ibuf, FE_MSG_ERROR); free (ibuf); + free (kb); return 5; } diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index fee8f320..2dfb7b8d 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -1646,7 +1646,8 @@ mg_create_tabmenu (session *sess, GdkEventButton *event, chan *ch) mg_destroy_tab_cb, ch); if (sess && tabmenu_list) menu_create (menu, tabmenu_list, sess->channel, FALSE); - menu_add_plugin_items (menu, "\x4$TAB", sess->channel); + if (sess) + menu_add_plugin_items (menu, "\x4$TAB", sess->channel); if (event->window) gtk_menu_set_screen (GTK_MENU (menu), gdk_drawable_get_screen (event->window)); diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index bd9d2d1a..21db1bbd 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -116,7 +116,6 @@ fe_new_window (struct session *sess, int focus) #endif "\n\n", 0); fflush (stdout); - fflush (stdin); } static int @@ -506,6 +505,7 @@ fe_args (int argc, char *argv[]) *sl = 0; printf ("%s\\plugins\n", exe); } + free (exe); #else printf ("%s\n", HEXCHATLIBDIR"/plugins"); #endif -- cgit 1.4.1 From 672dbf75d6d3d47135be49568ebcce917d6c188c Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Wed, 9 Jan 2013 14:53:19 -0800 Subject: Oops, fixed error in util.c --- src/common/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/util.c b/src/common/util.c index 38537402..2319f75e 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1319,7 +1319,7 @@ int my_poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) { if (*argv[argc]) { buf++, argc++; if (argc == argvAlloced) { - char *temp[]; + char **temp; argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA; temp = realloc(argv, sizeof(*argv) * argvAlloced); if (temp) -- cgit 1.4.1 From 475eb9fcaab1d846a3617f587f22bd77cdeddd5e Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Thu, 10 Jan 2013 00:13:25 -0800 Subject: Fix crash by detecting NULL channel in url_join_only() and just returning. --- src/common/outbound.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/common/outbound.c b/src/common/outbound.c index f8f73dd6..8241d78f 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -3350,6 +3350,8 @@ static void url_join_only (server *serv, char *tbuf, char *channel) { /* already connected, JOIN only. FIXME: support keys? */ + if (channel == NULL) + return; tbuf[0] = '#'; /* tbuf is 4kb */ safe_strcpy ((tbuf + 1), channel, 256); -- cgit 1.4.1