commit 49d9491bae0b3534083a5190de3250da3040f36d
parent 24e8816b793686174e1eca453350d9e613d13e56
Author: Colin Leroy <colin@colino.net>
Date: Fri, 13 Nov 2015 10:49:25 +0100
More null pointer dereference fixes
Diffstat:
7 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/plugins/archive/libarchive_archive.c b/src/plugins/archive/libarchive_archive.c
@@ -157,10 +157,10 @@ static GDate* iso2GDate(const gchar* date) {
gdate = g_date_new();
parts = g_strsplit(date, "-", 3);
- if (! is_iso_string(parts))
- return NULL;
if (!parts)
return NULL;
+ if (! is_iso_string(parts))
+ return NULL;
for (i = 0; i < 3; i++) {
int t = atoi(parts[i]);
switch (i) {
diff --git a/src/plugins/managesieve/managesieve.c b/src/plugins/managesieve/managesieve.c
@@ -620,7 +620,7 @@ static void parse_response(gchar *msg, SieveResult *result)
}
/* response code */
- if (msg[0] == '(' && (end = strchr(msg, ')'))) {
+ if (msg && msg[0] == '(' && (end = strchr(msg, ')'))) {
msg++;
*end++ = '\0';
result->code =
@@ -635,7 +635,7 @@ static void parse_response(gchar *msg, SieveResult *result)
}
/* s2c octets */
- if (msg[0] == '{' && (end = strchr(msg, '}'))) {
+ if (msg && msg[0] == '{' && (end = strchr(msg, '}'))) {
msg++;
*end++ = '\0';
if (msg[0] == '0' && msg+1 == end) {
@@ -654,7 +654,7 @@ static void parse_response(gchar *msg, SieveResult *result)
}
/* text */
- if (*msg) {
+ if (msg && *msg) {
unquote_inplace(msg);
result->description = msg;
} else {
diff --git a/src/plugins/pdf_viewer/poppler_viewer.c b/src/plugins/pdf_viewer/poppler_viewer.c
@@ -1486,7 +1486,8 @@ static void pdf_viewer_show_mimepart(MimeViewer *_viewer, const gchar *infile,
pdf_viewer_update((MimeViewer *)viewer, TRUE, 1);
- messageview->updating = FALSE;
+ if (messageview)
+ messageview->updating = FALSE;
}
static void pdf_viewer_clear(MimeViewer *_viewer)
diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c
@@ -275,7 +275,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
clist = sk->clist;
cm_return_val_if_fail (clist, NULL);
- debug_print ("select_keys:fill_clist: pattern '%s' proto %d\n", pattern, proto);
+ debug_print ("select_keys:fill_clist: pattern '%s' proto %d\n", pattern != NULL ? pattern : "NULL", proto);
/*gtk_cmclist_freeze (select_keys.clist);*/
err = gpgme_new (&ctx);
@@ -291,7 +291,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
err = gpgme_op_keylist_start (ctx, pattern, 0);
if (err) {
debug_print ("** gpgme_op_keylist_start(%s) failed: %s",
- pattern, gpgme_strerror (err));
+ pattern != NULL ? pattern : "NULL", gpgme_strerror (err));
sk->select_ctx = NULL;
gpgme_release(ctx);
return NULL;
@@ -312,7 +312,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
continue;
raw_mail = g_strdup(uid->email);
extract_address(raw_mail);
- if (!strcasecmp(pattern, raw_mail)) {
+ if (pattern != NULL && !strcasecmp(pattern, raw_mail)) {
exact_match = TRUE;
last_uid = uid;
g_free(raw_mail);
diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c
@@ -325,7 +325,7 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status)
case GPG_ERR_NO_ERROR:
g_string_append_printf(siginfo,
_("Good signature from uid \"%s\" (Validity: %s)\n"),
- uid, get_validity_str(key->uids?key->uids->validity:GPGME_VALIDITY_UNKNOWN));
+ uid, get_validity_str((key && key->uids) ? key->uids->validity:GPGME_VALIDITY_UNKNOWN));
break;
case GPG_ERR_KEY_EXPIRED:
g_string_append_printf(siginfo,
@@ -335,7 +335,7 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status)
case GPG_ERR_SIG_EXPIRED:
g_string_append_printf(siginfo,
_("Expired signature from uid \"%s\" (Validity: %s)\n"),
- uid, get_validity_str(key->uids?key->uids->validity:GPGME_VALIDITY_UNKNOWN));
+ uid, get_validity_str((key && key->uids) ? key->uids->validity:GPGME_VALIDITY_UNKNOWN));
break;
case GPG_ERR_CERT_REVOKED:
g_string_append_printf(siginfo,
@@ -352,17 +352,19 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status)
}
if (sig->status != GPG_ERR_BAD_SIGNATURE) {
gint j = 1;
- key->uids = key->uids ? key->uids->next : NULL;
- while (key->uids != NULL) {
- g_string_append_printf(siginfo,
- _(" uid \"%s\" (Validity: %s)\n"),
- key->uids->uid,
- key->uids->revoked==TRUE?_("Revoked"):get_validity_str(key->uids->validity));
- j++;
- key->uids = key->uids->next;
+ if (key) {
+ key->uids = key->uids ? key->uids->next : NULL;
+ while (key->uids != NULL) {
+ g_string_append_printf(siginfo,
+ _(" uid \"%s\" (Validity: %s)\n"),
+ key->uids->uid,
+ key->uids->revoked==TRUE?_("Revoked"):get_validity_str(key->uids->validity));
+ j++;
+ key->uids = key->uids->next;
+ }
}
g_string_append_printf(siginfo,_("Owner Trust: %s\n"),
- get_owner_trust_str(key->owner_trust));
+ key ? get_owner_trust_str(key->owner_trust) : _("No key!"));
g_string_append(siginfo,
_("Primary key fingerprint:"));
const char* primary_fpr = NULL;
diff --git a/src/plugins/python/python-hooks.c b/src/plugins/python/python-hooks.c
@@ -275,8 +275,10 @@ parasite_python_run(const char *command,
if (repr != NULL) {
char *string = PyString_AsString(repr);
- stdout_logger(string, user_data);
- stdout_logger("\n", user_data);
+ if (stdout_logger != NULL) {
+ stdout_logger(string, user_data);
+ stdout_logger("\n", user_data);
+ }
}
Py_XDECREF(repr);
diff --git a/src/plugins/rssyl/libfeed/parser_atom10.c b/src/plugins/rssyl/libfeed/parser_atom10.c
@@ -83,12 +83,12 @@ void feed_parser_atom10_start(void *data, const gchar *el, const gchar **attr)
} else if( !strcmp(el, "link") ) {
/* Capture item URL, from the "url" XML attribute. */
if (ctx->curitem && ctx->location == FEED_LOC_ATOM10_ENTRY)
- ctx->curitem->url = g_strdup(feed_parser_get_attribute_value(attr, "href"));
+ ctx->curitem->url = g_strdup(feed_parser_get_attribute_value(attr, "href"));
} else if( !strcmp(el, "source") ) {
ctx->location = FEED_LOC_ATOM10_SOURCE;
} else ctx->location = FEED_LOC_ATOM10_ENTRY;
- if( !strcmp(el, "title") ) {
+ if( !strcmp(el, "title") && ctx->curitem != NULL) {
a = feed_parser_get_attribute_value(attr, "type");
if( !a || !strcmp(a, "text") )
ctx->curitem->title_format = FEED_ITEM_TITLE_TEXT;
@@ -98,7 +98,7 @@ void feed_parser_atom10_start(void *data, const gchar *el, const gchar **attr)
ctx->curitem->title_format = FEED_ITEM_TITLE_XHTML;
else
ctx->curitem->title_format = FEED_ITEM_TITLE_UNKNOWN;
- } else if (!strcmp(el, "content") ) {
+ } else if (!strcmp(el, "content") && ctx->curitem != NULL) {
a = feed_parser_get_attribute_value(attr, "type");
if (a && !strcmp(a, "xhtml")) {
ctx->curitem->xhtml_content = TRUE;