diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index 5e7ecbcc73e43360bea68b64452ab05f7296944d..5f1626eb0d8d171c83c255fe32c3fb8a009fc487 100644
--- a/src/xpdev/dirwrap.c
+++ b/src/xpdev/dirwrap.c
@@ -785,6 +785,8 @@ int delfiles(const char *inpath, const char *spec, size_t keep)
 		lastch=0;
 	else
 		lastch=inpath[inpath_len-1];
+	if(spec == NULL)
+		spec = ALLFILES;
 	path=(char *)malloc(inpath_len+1/*Delim*/+strlen(spec)+1/*Terminator*/);
 	if(path==NULL)
 		return -1;