GNU C Library master sources branch, master, updated. glibc-2.12-91-gf15ce4d
Andreas Schwab
schwab@redhat.com
Tue Nov 9 11:48:00 GMT 2010
Petr Baudis <pasky@suse.cz> writes:
> Hi!
>
> On Tue, Aug 10, 2010 at 04:10:03AM -0000, drepper@sourceware.org wrote:
>> - Log -----------------------------------------------------------------
>> http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f15ce4d8dc139523fe0c273580b604b2453acba6
>>
> ..snip..
>> diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
>> index 67c0ee4..c8e52a6 100644
>> --- a/posix/fnmatch_loop.c
>> +++ b/posix/fnmatch_loop.c
> ..snip..
>> @@ -1102,15 +1108,27 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
>> /* This means we found the end of the pattern. */
>> #define NEW_PATTERN \
>> struct patternlist *newp; \
>> - \
>> - if (opt == L('?') || opt == L('@')) \
>> - newp = alloca (sizeof (struct patternlist) \
>> - + (pattern_len * sizeof (CHAR))); \
>> + size_t slen = (opt == L('?') || opt == L('@') \
>> + ? pattern_len : (p - startp + 1)); \
>> + slen = sizeof (struct patternlist) + (slen * sizeof (CHAR)); \
>> + int malloced = ! __libc_use_alloca (alloca_used + slen); \
>> + if (__builtin_expect (malloced, 0)) \
>> + { \
>> + newp = alloca_account (slen, alloca_used); \
>> + any_malloced = 1; \
>> + } \
>> else \
>> - newp = alloca (sizeof (struct patternlist) \
>> - + ((p - startp + 1) * sizeof (CHAR))); \
>> - *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0'); \
>> + { \
>> + newp = malloc (slen); \
>> + if (newp == NULL) \
>> + { \
>> + retval = -2; \
>> + goto out; \
>> + } \
>> + } \
>> newp->next = NULL; \
>> + newp->malloced = malloced; \
>> + *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0'); \
>> *lastp = newp; \
>> lastp = &newp->next
>> NEW_PATTERN;
>
> I think you have meant to set any_malloced = 1 in the else branch
> instead?
Moreover, the condition is backwards.
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
More information about the Libc-alpha
mailing list