Hi Cedric, On Thu, Jan 24, 2013 at 12:44 AM, Enlightenment SVN <no-re...@enlightenment.org> wrote: > Log: > efl/eina: detect when freeing pointer inside an allocated memory. > > > Author: cedric > Date: 2013-01-23 18:44:14 -0800 (Wed, 23 Jan 2013) > New Revision: 83195 > Trac: http://trac.enlightenment.org/e/changeset/83195 > > Modified: > trunk/efl/src/modules/eina/mp/chained_pool/eina_chained_mempool.c > > Modified: trunk/efl/src/modules/eina/mp/chained_pool/eina_chained_mempool.c > =================================================================== > --- trunk/efl/src/modules/eina/mp/chained_pool/eina_chained_mempool.c > 2013-01-24 02:23:59 UTC (rev 83194) > +++ trunk/efl/src/modules/eina/mp/chained_pool/eina_chained_mempool.c > 2013-01-24 02:44:14 UTC (rev 83195) > @@ -211,15 +211,23 @@ > // pool mem base > pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool)); > > +#ifdef DEBUG > // is it in pool mem? > if (ptr < pmem) > { > -#ifdef DEBUG > - INF("%p is inside the private part of %p pool from %p > Chained_Mempool (could be the sign of a buffer underrun).", ptr, p, pool); > -#endif > + INF("%p is inside the private part of %p pool from %p '%s' > Chained_Mempool (could be the sign of a buffer underrun).", ptr, p, pool, > pool->name); > return EINA_FALSE; > } > > + // is it really a pointer returned by malloc > + if ((((unsigned char *)ptr) - (unsigned char *)(p + 1)) % > pool->item_alloc) > + { > + INF("%p is %i bytes inside a pointer served by %p '%s' > Chained_Mempool (You are freeing the wrong pointer man !). %i", > + ptr, ((((unsigned char *)ptr) - (unsigned char *)(p + 1)) % > pool->item_alloc), pool, pool->name); > + return EINA_FALSE; > + } > +#endif > + > // freed node points to prev free node > eina_trash_push(&p->base, ptr); > // next free node is now the one we freed
Nice. But shouldn't these messages be ERR or at least WRN? -- Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel