--- a/sched_getscheduler.c
+++ b/sched_getscheduler.c
@@ -62,6 +62,8 @@
 		 (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
 	      return -1;
 	    }
+	  else
+	    CloseHandle(h);
 	}
     }