* lib/glob.c (glob): Prefer SIZE_MAX to ~((size_t) 0), as the
latter is not portable to (probably theoretical) hosts where
SIZE_MAX <= INT_MAX.
+2016-05-12 Paul Eggert <eggert@cs.ucla.edu>
+
+ glob: don't assume INT_MAX < SIZE_MAX
+ * lib/glob.c (glob): Prefer SIZE_MAX to ~((size_t) 0), as the
+ latter is not portable to (probably theoretical) hosts where
+ SIZE_MAX <= INT_MAX.
+
2016-05-09 Bruno Haible <bruno@clisp.org>
Fix undefined behaviour in gettext.h.
{
size_t i;
- if (pglob->gl_offs >= ~((size_t) 0) / sizeof (char *))
+ if (pglob->gl_offs >= SIZE_MAX / sizeof (char *))
return GLOB_NOSPACE;
pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *));
char **new_gl_pathv;
if (newcount > UINTPTR_MAX - (1 + 1)
- || newcount + 1 + 1 > ~((size_t) 0) / sizeof (char *))
+ || newcount + 1 + 1 > SIZE_MAX / sizeof (char *))
{
nospace:
free (pglob->gl_pathv);
char **new_gl_pathv;
if (newcount > UINTPTR_MAX - 2
- || newcount + 2 > ~((size_t) 0) / sizeof (char *))
+ || newcount + 2 > SIZE_MAX / sizeof (char *))
{
nospace2:
globfree (&dirs);