Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search.c: Fix build failure due new GCC #1132

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cgi-bin/search.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Search routines for CUPS.
*
* Copyright © 2020-2024 by OpenPrinting.
* Copyright © 2020-2025 by OpenPrinting.
* Copyright © 2007-2018 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
*
Expand Down Expand Up @@ -169,26 +169,27 @@
if (wlen > slen)
{
/*
* Expand the RE string buffer...
* Expand the RE string buffer...
*/

char *temp; /* Temporary string pointer */
char *temp; /* Temporary string pointer */
const ptrdiff_t pos = sptr - s; /* Current pointer position (GCC workaround for use-after-free warning after realloc) */


slen = wlen + 128;
temp = (char *)realloc(s, slen);
temp = (char *)realloc(s, slen);
if (!temp)
{
free(s);
free(re);

if (lword)

Check notice

Code scanning / CodeQL

Guarded Free Note

unnecessary NULL check before call to
free
free(lword);
free(lword);

return (NULL);
}

sptr = temp + (sptr - s);
sptr = temp + pos;
s = temp;
}

Expand Down
Loading