[balsa] Fix some issues detected by cppcheck
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Fix some issues detected by cppcheck
- Date: Sat, 8 Dec 2018 19:51:43 +0000 (UTC)
commit e308add5a850706b1984e1fe35dc9fa586742edf
Author: Albrecht Dreß <albrecht dress arcor de>
Date: Sat Dec 8 14:51:04 2018 -0500
Fix some issues detected by cppcheck
* libbalsa/imap/auth-gssapi.c: fix (unlikely) uninitialised use of rc
* libbalsa/imap/imap-auth.c: do not dereference NULL pointer if
an error occurred
* libbalsa/libbalsa.c: fix signed/unsigned mismatch, and use
g_debug instead of printf
* libbalsa/mailbox_imap.c: fix signed/unsigned mismatch
* libinit_balsa/assistant_page_directory.c: fix different
parameters names in function prototype and implementation
* src/balsa-message.c, src/save-restore.c: do no dereference
pointer before checking it it is not NULL
* src/sendmsg-window.c: fix false-positive about NULL pointer dereference
* src/store-address.c: fix false-positive by splitting an
over-complex construct
Signed-off-by: Peter Bloomfield <PeterBloomfield bellsouth net>
ChangeLog | 18 ++++++++++++++++++
libbalsa/imap/auth-gssapi.c | 2 ++
libbalsa/imap/imap-auth.c | 8 +++++---
libbalsa/libbalsa.c | 2 +-
libbalsa/mailbox_imap.c | 4 ++--
libinit_balsa/assistant_page_directory.c | 2 +-
src/balsa-message.c | 3 ++-
src/save-restore.c | 3 ++-
src/sendmsg-window.c | 3 +--
src/store-address.c | 7 +++++--
10 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e3ce8070e..0d39a92f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2018-12-08 Albrecht Dreß <albrecht dress arcor de>
+
+ Fix some issues detected by cppcheck
+
+ * libbalsa/imap/auth-gssapi.c: fix (unlikely) uninitialised use of rc
+ * libbalsa/imap/imap-auth.c: do not dereference NULL pointer if
+ an error occurred
+ * libbalsa/libbalsa.c: fix signed/unsigned mismatch, and use
+ g_debug instead of printf
+ * libbalsa/mailbox_imap.c: fix signed/unsigned mismatch
+ * libinit_balsa/assistant_page_directory.c: fix different
+ parameters names in function prototype and implementation
+ * src/balsa-message.c, src/save-restore.c: do no dereference
+ pointer before checking it it is not NULL
+ * src/sendmsg-window.c: fix false-positive about NULL pointer dereference
+ * src/store-address.c: fix false-positive by splitting an
+ over-complex construct
+
2018-12-04 Peter Bloomfield <pbloomfield bellsouth net>
Deprecation cleanup
diff --git a/libbalsa/imap/auth-gssapi.c b/libbalsa/imap/auth-gssapi.c
index 14a2de569..e70d560a2 100644
--- a/libbalsa/imap/auth-gssapi.c
+++ b/libbalsa/imap/auth-gssapi.c
@@ -148,6 +148,8 @@ imap_auth_gssapi(ImapMboxHandle* handle)
(void) net_client_write_line(NET_CLIENT(handle->sio), "*", NULL);
}
rc = imap_cmd_process_untagged(handle, cmdno);
+ } else {
+ rc = IMR_BAD;
}
net_client_gss_ctx_free(gss_ctx);
diff --git a/libbalsa/imap/imap-auth.c b/libbalsa/imap/imap-auth.c
index febc0859a..91335bd50 100644
--- a/libbalsa/imap/imap-auth.c
+++ b/libbalsa/imap/imap-auth.c
@@ -182,9 +182,11 @@ getmsg_plain(ImapMboxHandle *h, char **retmsg, int *retmsglen)
*retmsglen = strlen(*retmsg);
result = TRUE;
}
- net_client_free_authstr(auth_data[0]);
- net_client_free_authstr(auth_data[1]);
- g_free(auth_data);
+ if (auth_data != NULL) {
+ net_client_free_authstr(auth_data[0]);
+ net_client_free_authstr(auth_data[1]);
+ g_free(auth_data);
+ }
return result;
}
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 38096642c..090a0fcff 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -616,7 +616,7 @@ ask_cert_real(void *data)
* not really necessary but helps with debugging. */
while(gtk_events_pending())
gtk_main_iteration_do(FALSE);
- printf("%s returns %d\n", __FUNCTION__, i);
+ g_debug("%s returns %u", __func__, i);
return i;
}
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 70a7650a3..128ebd357 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -2313,9 +2313,9 @@ static gboolean
is_child_of(LibBalsaMessageBody *body, LibBalsaMessageBody *child,
GString *s, gboolean modify)
{
- int i = 1;
+ guint i;
gboolean do_mod;
- for(i=1; body; body = body->next) {
+ for(i=1U; body; body = body->next) {
if(body==child) {
g_string_printf(s, "%u", i);
return TRUE;
diff --git a/libinit_balsa/assistant_page_directory.c b/libinit_balsa/assistant_page_directory.c
index 279fdfc77..7499884ce 100644
--- a/libinit_balsa/assistant_page_directory.c
+++ b/libinit_balsa/assistant_page_directory.c
@@ -389,7 +389,7 @@ balsa_druid_page_directory_back(GtkAssistant *druid, GtkWidget *page,
}
static void
-balsa_druid_page_directory_next(GtkAssistant * page, GtkWidget * druid,
+balsa_druid_page_directory_next(GtkAssistant *druid, GtkWidget *page,
BalsaDruidPageDirectory * dir)
{
dir->paths_locked = TRUE;
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 98d10468e..1ad4ec1dc 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1136,10 +1136,11 @@ balsa_message_set(BalsaMessage * bm, LibBalsaMailbox * mailbox, guint msgno)
gboolean is_new;
GtkTreeIter iter;
BalsaPartInfo *info;
- gboolean has_focus = bm->focus_state != BALSA_MESSAGE_FOCUS_STATE_NO;
+ gboolean has_focus;
LibBalsaMessage *message;
g_return_val_if_fail(bm != NULL, FALSE);
+ has_focus = bm->focus_state != BALSA_MESSAGE_FOCUS_STATE_NO;
bm_disable_find_entry(bm);
balsa_message_clear_tree(bm);
diff --git a/src/save-restore.c b/src/save-restore.c
index 0615326f6..3d306be24 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -449,9 +449,10 @@ static gint
config_mailbox_init(const gchar * prefix)
{
LibBalsaMailbox *mailbox;
- const gchar *key = prefix + strlen(MAILBOX_SECTION_PREFIX);
+ const gchar *key;
g_return_val_if_fail(prefix != NULL, FALSE);
+ key = prefix + strlen(MAILBOX_SECTION_PREFIX);
mailbox = libbalsa_mailbox_new_from_config(prefix, is_special_name(key));
if (mailbox == NULL)
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 7244a76c2..5e39b2715 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -6239,8 +6239,7 @@ sendmsg_window_new_from_list(LibBalsaMailbox * mailbox,
break;
default:
g_assert_not_reached(); /* since it hardly makes sense... */
- bsmsg = NULL; /** silence invalid warnings */
-
+ return NULL; /* silence invalid warnings */
}
g_object_unref(message);
diff --git a/src/store-address.c b/src/store-address.c
index 5efd9aebb..0130e5233 100644
--- a/src/store-address.c
+++ b/src/store-address.c
@@ -375,8 +375,11 @@ store_address_add_address(StoreAddressInfo * info,
text = internet_address_to_string(ia, FALSE);
address = libbalsa_address_new();
- address->full_name =
- g_strdup(ia->name ? ia->name : group ? group->name : NULL);
+ if (ia->name != NULL) {
+ address->full_name = g_strdup(ia->name);
+ } else {
+ address->full_name = g_strdup((group != NULL) ? group->name : NULL);
+ }
if (INTERNET_ADDRESS_IS_GROUP(ia)) {
InternetAddressList *members;
int j;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]