--- rlm_detail.c	2011-05-18 09:37:28.000000000 +0300
+++ rlm_detail.c.new	2011-05-18 09:41:26.000000000 +0300
@@ -185,6 +185,7 @@
 	int		lock_count;
 	struct timeval	tv;
 	VALUE_PAIR	*pair;
+	int             fpf;
 
 	struct detail_instance *inst = instance;
 
@@ -463,7 +464,11 @@
 		RDEBUG2("Released filelock");
 	}
 
-	fclose(outfp);
+	fpf = fclose(outfp);
+	if (fpf == EOF) {
+	        radlog(L_ERR,"rlm_detail: cannot close the file! (%s)", strerror(errno));
+		return RLM_MODULE_FAIL;
+	}
 
 	/*
 	 *	And everything is fine.
