Commit fad674f5 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez

hardening delete operator

Make sure that delete operator is not called with invalid pointers.

Change-Id: I822b670c63bd40234aef0213517914fdcc7b68e9
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent d532c74f
......@@ -109,7 +109,10 @@ account_security_tab_finalize(GObject *object)
AccountSecurityTab *view = ACCOUNT_SECURITY_TAB(object);
AccountSecurityTabPrivate *priv = ACCOUNT_SECURITY_TAB_GET_PRIVATE(view);
delete priv->qmodel_key_exchange;
if (priv->qmodel_key_exchange) {
delete priv->qmodel_key_exchange;
priv->qmodel_key_exchange = nullptr;
}
G_OBJECT_CLASS(account_security_tab_parent_class)->finalize(object);
}
......
......@@ -180,7 +180,10 @@ choose_contact_view_finalize(GObject *object)
ChooseContactView *self = CHOOSE_CONTACT_VIEW(object);
ChooseContactViewPrivate *priv = CHOOSE_CONTACT_VIEW_GET_PRIVATE(self);
delete priv->sorted_contacts;
if (priv->sorted_contacts) {
delete priv->sorted_contacts;
priv->sorted_contacts = nullptr;
}
G_OBJECT_CLASS(choose_contact_view_parent_class)->finalize(object);
}
......
......@@ -673,7 +673,10 @@ gtk_q_tree_model_finalize(GObject *object)
g_free(priv->column_roles);
/* delete the created proxy model */
delete priv->model;
if (not priv->model) {
delete priv->model;
priv->model = nullptr;
}
G_OBJECT_CLASS(gtk_q_tree_model_parent_class)->finalize (object);
}
......
......@@ -751,7 +751,10 @@ ring_client_shutdown(GApplication *app)
/* free the QCoreApplication, which will destroy all libRingClient models
* and thus send the Unregister signal over dbus to dring */
delete priv->qtapp;
if (priv->qtapp) {
delete priv->qtapp;
priv->qtapp = nullptr;
}
/* free the copied cmd line args */
g_strfreev(priv->argv);
......
......@@ -376,7 +376,10 @@ show_message_if_unread(const QModelIndex *idx)
static void
delete_idx(QModelIndex *idx)
{
delete idx;
if (idx) {
delete idx;
idx = nullptr;
}
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment