From 2ab6547cf9d45f3f3de104c41abefcbd236c7f94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sun, 13 May 2012 17:13:50 +0200
Subject: [PATCH] Stdio.File: Fixed argument checking for
 set_fs_event_callback().

---
 src/modules/files/file.c           | 7 +++++--
 src/modules/files/file_functions.h | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/modules/files/file.c b/src/modules/files/file.c
index 6f7efce7bf..b39db7d733 100644
--- a/src/modules/files/file.c
+++ b/src/modules/files/file.c
@@ -1730,9 +1730,12 @@ static void set_fd_event_cb (struct my_file *f, struct svalue *cb, int event, in
 #define CBFUNCS2(CB, EVENT)						\
   static void PIKE_CONCAT(file_set_,CB) (INT32 args)			\
   {									\
-    if(!args)								\
+    if(args<2)								\
       SIMPLE_TOO_FEW_ARGS_ERROR("Stdio.File->set_" #CB, 2);		\
-    set_fd_event_cb (THIS, Pike_sp-args, EVENT, Pike_sp[-1].u.integer);	\
+    if (TYPEOF(Pike_sp[1-args]) != T_INT)				\
+      SIMPLE_ARG_TYPE_ERROR("Stdio.File->set_" #CB, 2, "int");		\
+    set_fd_event_cb (THIS, Pike_sp-args, EVENT,				\
+		     Pike_sp[1-args].u.integer);			\
   }									\
 									\
   static void PIKE_CONCAT(file_query_,CB) (INT32 args)			\
diff --git a/src/modules/files/file_functions.h b/src/modules/files/file_functions.h
index 675ab04ca3..baf5e4356d 100644
--- a/src/modules/files/file_functions.h
+++ b/src/modules/files/file_functions.h
@@ -82,7 +82,7 @@ FILE_FUNC("set_write_callback",file_set_write_callback, tFunc(CB_FUNC,tVoid))
 FILE_FUNC("set_read_oob_callback",file_set_read_oob_callback, tFunc(CB_FUNC,tVoid))
 /* function(mixed:void) */
 FILE_FUNC("set_write_oob_callback",file_set_write_oob_callback, tFunc(CB_FUNC,tVoid))
-/* function(mixed:void) */
+/* function(mixed,int:void) */
 FILE_FUNC("set_fs_event_callback",file_set_fs_event_callback, tFunc(tFunc(tInt,tOr(tVoid,tMixed)) tInt,tVoid))
 
 FILE_FUNC("query_fs_event_flags",file_query_fs_event_flags, tFunc(tVoid,tInt))
-- 
GitLab