--- a/agent/mibgroup/host/data_access/swinst_pkginfo.c.orig
+++ b/agent/mibgroup/host/data_access/swinst_pkginfo.c
@@ -207,7 +207,9 @@
 	    memcpy( entry->swDate, cp, date_len );
 	    entry->swDate_len = date_len;
 	}
-	closedir( d );
+	if (d != NULL)
+		closedir( d );
+
 #ifdef HAVE_LIBPKG
     }
 #endif