]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
search.c: newer free() accepts NULL
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 7 Jan 2025 17:49:53 +0000 (18:49 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 7 Jan 2025 17:49:53 +0000 (18:49 +0100)
cgi-bin/search.c

index 823d0565250bf15e432870228b180a1ccb9745bd..136d12d5691b4a6d61b5a7d5008de81a1dc7232e 100644 (file)
@@ -105,14 +105,13 @@ cgiCompileSearch(const char *query)       /* I - Query string */
       if (!*qend)
       {
        /*
-        * No closing quote, error out!
+       * No closing quote, error out!
        */
 
        free(s);
        free(re);
 
-       if (lword)
-          free(lword);
+       free(lword);
 
        return (NULL);
       }
@@ -140,7 +139,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
       */
 
       if (sptr > s)
-        prefix = ".*";
+       prefix = ".*";
 
       qptr = qend;
     }
@@ -151,7 +150,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
       */
 
       if (sptr > s)
-        prefix = ".*|.*";
+       prefix = ".*|.*";
 
       qptr = qend;
     }
@@ -164,7 +163,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
 
       wlen = (size_t)(sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
       if (lword)
-        wlen += strlen(lword);
+       wlen += strlen(lword);
 
       if (wlen > slen)
       {
@@ -183,8 +182,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
          free(s);
          free(re);
 
-         if (lword)
-           free(lword);
+         free(lword);
 
          return (NULL);
        }
@@ -210,10 +208,10 @@ cgiCompileSearch(const char *query)       /* I - Query string */
       while (qptr < qend)
       {
        /*
-        * Quote: ^ . [ $ ( ) | * + ? { \
+       * Quote: ^ . [ $ ( ) | * + ? { \
        */
 
-        if (strchr("^.[$()|*+?{\\", *qptr))
+       if (strchr("^.[$()|*+?{\\", *qptr))
          *sptr++ = '\\';
 
        *sptr++ = *qptr++;
@@ -227,10 +225,10 @@ cgiCompileSearch(const char *query)       /* I - Query string */
 
       if (!strcmp(prefix, ".*") && lword)
       {
-        char *lword2;                  /* New "last word" */
+       char *lword2;                   /* New "last word" */
 
 
-        if ((lword2 = strdup(sword)) == NULL)
+       if ((lword2 = strdup(sword)) == NULL)
        {
          free(lword);
          free(s);
@@ -238,25 +236,24 @@ cgiCompileSearch(const char *query)       /* I - Query string */
          return (NULL);
        }
 
-        memcpy(sptr, ".*|.*", 6);
+       memcpy(sptr, ".*|.*", 6);
        sptr += 5;
 
        memcpy(sptr, lword2, strlen(lword2) + 1);
        sptr += strlen(sptr);
 
-        memcpy(sptr, ".*", 3);
+       memcpy(sptr, ".*", 3);
        sptr += 2;
 
        memcpy(sptr, lword, strlen(lword) + 1);
        sptr += strlen(sptr);
 
-        free(lword);
+       free(lword);
        lword = lword2;
       }
       else
       {
-       if (lword)
-          free(lword);
+       free(lword);
 
        lword = strdup(sword);
       }
@@ -272,8 +269,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
       qptr ++;
   }
 
-  if (lword)
-    free(lword);
+  free(lword);
 
   if (sptr > s)
     memcpy(sptr, ".*", 3);