Index: branches/reyalp-flt/core/module_wrappers.c
===================================================================
--- branches/reyalp-flt/core/module_wrappers.c	(revision 1498)
+++ branches/reyalp-flt/core/module_wrappers.c	(revision 1512)
@@ -40,4 +40,5 @@
 }
 
+#define MAGICNUM_OPENDIR 0xf8bd35de
 
 //-------------------------------------------------------
@@ -56,4 +57,5 @@
 
 	memset( std, 0, sizeof(STD_DIR));
+	std->magicnum = MAGICNUM_OPENDIR;
 	std->dh = dh;
 
@@ -67,5 +69,7 @@
 
 	if ( dir==0 ) return 0;
+	if ( dir->magicnum!=MAGICNUM_OPENDIR ) return 0;
 	rv = closedir( dir->dh );
+	dir->magicnum=0;
 	free( dir );
 	return rv;
@@ -88,4 +92,5 @@
 
 	if ( dir==0 ) return 0;
+	if ( dir->magicnum!=MAGICNUM_OPENDIR ) return 0;
 	de = readdir( dir->dh );
 
