After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688430 - file-manager: Fix invalid unref of NULL pointer.
file-manager: Fix invalid unref of NULL pointer.
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: file-manager
unspecified
Other All
: Normal normal
: ---
Assigned To: Johannes Schmid
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-15 22:44 UTC by Carl-Anton Ingmarsson
Modified: 2012-11-17 11:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
file-manager: Fix invalid unref of NULL pointer. (828 bytes, patch)
2012-11-15 22:44 UTC, Carl-Anton Ingmarsson
committed Details | Review

Description Carl-Anton Ingmarsson 2012-11-15 22:44:01 UTC
As summary says.
Comment 1 Carl-Anton Ingmarsson 2012-11-15 22:44:03 UTC
Created attachment 229102 [details] [review]
file-manager: Fix invalid unref of NULL pointer.
Comment 2 Sébastien Granjoux 2012-11-17 09:52:18 UTC
Review of attachment 229102 [details] [review]:

Thanks for your patch

Here is the corresponding code:
do
{
	GFile* model_file;
	gtk_tree_model_get (GTK_TREE_MODEL(model), &file_iter,
						COLUMN_FILE, &model_file, -1);
	if (model_file && file && g_file_equal (model_file, file))
	{
		g_object_unref (model_file);
		found = TRUE;
		break;
	}
	g_clear_object (&model_file);
}
while (gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &file_iter));

I think a better solution will be to initialized model_file to NULL and keep the g_object_unref. Using g_clear_object does not fix the issue for the first loop iteration. Do you agree?
Comment 3 Carl-Anton Ingmarsson 2012-11-17 10:32:12 UTC
The gtk_tree_model_get() will set model_file to a valid file or NULL. Using g_clear_object() or "if (model_file) g_object_unref (model_file)" is both ok. Which one to choose is purely stylistic in this case.
Comment 4 Sébastien Granjoux 2012-11-17 10:36:49 UTC
Review of attachment 229102 [details] [review]:

Ok, I have missed it, then your patch is just fine. Thanks.