diff options
author | Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com> | 2016-07-11 14:16:01 -0300 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com> | 2016-07-11 14:16:01 -0300 |
commit | bde2a94b61d1cef444d7d4b4b9db70062c48cf5d (patch) | |
tree | 5393a8c666de2fb8995df1282909c09ed17d9351 /catgets/catgets.c | |
parent | 3f1ff80d9a0c60398e73d62c52f9a2f06af8d61d (diff) | |
parent | 66986dec455c2011085a04b72a5bd55d9f9c7d1c (diff) | |
download | glibc-bde2a94b61d1cef444d7d4b4b9db70062c48cf5d.zip glibc-bde2a94b61d1cef444d7d4b4b9db70062c48cf5d.tar.gz glibc-bde2a94b61d1cef444d7d4b4b9db70062c48cf5d.tar.bz2 |
Merge branch 'release/2.19/master' into ibm/2.19/masteribm/2.19/master
Conflicts:
NEWS
Diffstat (limited to 'catgets/catgets.c')
-rw-r--r-- | catgets/catgets.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/catgets/catgets.c b/catgets/catgets.c index eac2827..820c0f6 100644 --- a/catgets/catgets.c +++ b/catgets/catgets.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <alloca.h> #include <errno.h> #include <locale.h> #include <nl_types.h> @@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag) __nl_catd result; const char *env_var = NULL; const char *nlspath = NULL; + char *tmp = NULL; if (strchr (cat_name, '/') == NULL) { @@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag) { /* Append the system dependent directory. */ size_t len = strlen (nlspath) + 1 + sizeof NLSPATH; - char *tmp = alloca (len); + tmp = malloc (len); + + if (__glibc_unlikely (tmp == NULL)) + return (nl_catd) -1; __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH); nlspath = tmp; @@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag) result = (__nl_catd) malloc (sizeof (*result)); if (result == NULL) - /* We cannot get enough memory. */ - return (nl_catd) -1; - - if (__open_catalog (cat_name, nlspath, env_var, result) != 0) + { + /* We cannot get enough memory. */ + result = (nl_catd) -1; + } + else if (__open_catalog (cat_name, nlspath, env_var, result) != 0) { /* Couldn't open the file. */ free ((void *) result); - return (nl_catd) -1; + result = (nl_catd) -1; } + free (tmp); return (nl_catd) result; } |