summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/lib/match.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_install/lib/match.c')
-rw-r--r--usr.sbin/pkg_install/lib/match.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/lib/match.c b/usr.sbin/pkg_install/lib/match.c
index 2bcae2a..f3dc999 100644
--- a/usr.sbin/pkg_install/lib/match.c
+++ b/usr.sbin/pkg_install/lib/match.c
@@ -24,7 +24,6 @@ static const char rcsid[] =
*/
#include "lib.h"
-
#include <err.h>
#include <fnmatch.h>
#include <fts.h>
@@ -97,14 +96,18 @@ matchinstalled(match_t MatchType, char **patterns, int *retval)
}
/* Count number of patterns */
- for (len = 0; patterns[len]; len++) {}
- lmatched = alloca(sizeof(*lmatched) * len);
- if (lmatched == NULL) {
- warnx("%s(): alloca() failed", __FUNCTION__);
- if (retval != NULL)
- *retval = 1;
- return NULL;
- }
+ if (patterns != NULL) {
+ for (len = 0; patterns[len]; len++) {}
+ lmatched = alloca(sizeof(*lmatched) * len);
+ if (lmatched == NULL) {
+ warnx("%s(): alloca() failed", __FUNCTION__);
+ if (retval != NULL)
+ *retval = 1;
+ return NULL;
+ }
+ } else
+ len = 0;
+
for (i = 0; i < len; i++)
lmatched[i] = FALSE;
OpenPOWER on IntegriCloud