CamelIMAPXJob: Fill memory with a bit pattern before freeing.
authorMatthew Barnes <mbarnes@redhat.com>
Fri, 23 Mar 2012 16:38:40 +0000 (12:38 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Sun, 25 Mar 2012 22:44:45 +0000 (18:44 -0400)
To help track down finalized CamelIMAPXJobs being passed around.

camel/providers/imapx/camel-imapx-job.c

index e5b5552..c8fc68a 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "camel-imapx-job.h"
 
+#include <string.h>
+
 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);
        }
 }