summaryrefslogtreecommitdiff
path: root/cgi-bin/search.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-01-17 00:06:33 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2008-01-17 00:06:33 +0000
commit91c84a3551145559de2956179661e111e373db95 (patch)
treeea061b2b6ab3b9e4530347e35f5cde3511f8a305 /cgi-bin/search.c
parent080811b190031b9182e96dc76fc610fadfeaec21 (diff)
downloadcups-91c84a3551145559de2956179661e111e373db95.tar.gz
Import CUPS 1.4svn-r7226.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@582 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cgi-bin/search.c')
-rw-r--r--cgi-bin/search.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/cgi-bin/search.c b/cgi-bin/search.c
index 9765064f0..4ec4de397 100644
--- a/cgi-bin/search.c
+++ b/cgi-bin/search.c
@@ -3,7 +3,7 @@
*
* Search routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
@@ -53,7 +53,8 @@ cgiCompileSearch(const char *query) /* I - Query string */
* Allocate a regular expression storage structure...
*/
- re = (regex_t *)calloc(1, sizeof(regex_t));
+ if ((re = (regex_t *)calloc(1, sizeof(regex_t))) == NULL)
+ return (NULL);
/*
* Allocate a buffer to hold the regular expression string, starting
@@ -65,7 +66,11 @@ cgiCompileSearch(const char *query) /* I - Query string */
if (slen < 1024)
slen = 1024;
- s = (char *)malloc(slen);
+ if ((s = (char *)malloc(slen)) == NULL)
+ {
+ free(re);
+ return (NULL);
+ }
/*
* Copy the query string to the regular expression, handling basic
@@ -227,7 +232,13 @@ cgiCompileSearch(const char *query) /* I - Query string */
char *lword2; /* New "last word" */
- lword2 = strdup(sword);
+ if ((lword2 = strdup(sword)) == NULL)
+ {
+ free(lword);
+ free(s);
+ free(re);
+ return (NULL);
+ }
strcpy(sptr, ".*|.*");
sptr += 5;