[evolution-data-server] CamelIMAPXJob: Fill memory with a bit pattern before freeing.



commit 0a24ca38fc69bbc0be57df1afcb2d3928c6b878e
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Mar 23 12:38:40 2012 -0400

    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 files changed, 11 insertions(+), 0 deletions(-)
---
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 <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);
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]