From 0a24ca38fc69bbc0be57df1afcb2d3928c6b878e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 23 Mar 2012 12:38:40 -0400 Subject: [PATCH] CamelIMAPXJob: Fill memory with a bit pattern before freeing. To help track down finalized CamelIMAPXJobs being passed around. --- camel/providers/imapx/camel-imapx-job.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/camel/providers/imapx/camel-imapx-job.c b/camel/providers/imapx/camel-imapx-job.c index e5b5552..c8fc68a 100644 --- a/camel/providers/imapx/camel-imapx-job.c +++ b/camel/providers/imapx/camel-imapx-job.c @@ -18,6 +18,8 @@ #include "camel-imapx-job.h" +#include + typedef struct _CamelIMAPXRealJob CamelIMAPXRealJob; /* CamelIMAPXJob + some private bits */ @@ -113,6 +115,15 @@ camel_imapx_job_unref (CamelIMAPXJob *job) if (real_job->destroy_data != NULL) real_job->destroy_data (real_job->data); + /* Fill the memory with a bit pattern before releasing + * it back to the slab allocator, so we can more easily + * identify dangling CamelIMAPXJob pointers. */ + memset (real_job, 0xaa, sizeof (CamelIMAPXRealJob)); + + /* But leave the reference count set to zero, so + * CAMEL_IS_IMAPX_JOB can identify it as bad. */ + real_job->ref_count = 0; + g_slice_free (CamelIMAPXRealJob, real_job); } } -- 2.7.4