[PATCH 1/2] glob: don't assume INT_MAX < SIZE_MAX

2016-05-12 Thread Paul Eggert
* 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. --- ChangeLog | 7 +++ lib/glob.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8ba38e..4a

[PATCH 2/2] glob: size_t overflow checks

2016-05-12 Thread Paul Eggert
* lib/glob.c (__has_builtin): New macro. (size_add_wrapv, glob_use_alloca): New static functions. (glob, glob_in_dir): Check for size_t overflow in several places, and fix some size_t checks that were not quite right. --- ChangeLog | 6 +++ lib/glob.c | 162 +++--

Re: [PATCH v2] gettext-h: avoid undefined behavior

2016-05-12 Thread Daiki Ueno
Bruno Haible writes: > While your patch is correct, I don't like that much code that > - does free(NULL) in the main execution path of the code, > - does computations such as (n == 1 ? msgid : msgid_plural) > before they turn out to be needed. > - assigns a variable in several places in