svn commit: r286522 - projects/collation/lib/libc/locale
Baptiste Daroussin
bapt at FreeBSD.org
Sun Aug 9 12:13:31 UTC 2015
Author: bapt
Date: Sun Aug 9 12:13:30 2015
New Revision: 286522
URL: https://svnweb.freebsd.org/changeset/base/286522
Log:
Use more asprintf
Plug memory leak introduced in previous asprintf addition
Modified:
projects/collation/lib/libc/locale/collate.c
projects/collation/lib/libc/locale/setrunelocale.c
Modified: projects/collation/lib/libc/locale/collate.c
==============================================================================
--- projects/collation/lib/libc/locale/collate.c Sun Aug 9 11:50:50 2015 (r286521)
+++ projects/collation/lib/libc/locale/collate.c Sun Aug 9 12:13:30 2015 (r286522)
@@ -124,8 +124,10 @@ __collate_load_tables_l(const char *enco
if (buf == NULL)
return (_LDP_ERROR);
- if ((fd = _open(buf, O_RDONLY)) < 0)
+ if ((fd = _open(buf, O_RDONLY)) < 0) {
+ free(buf);
return (_LDP_ERROR);
+ }
free(buf);
if (_fstat(fd, &sbuf) < 0) {
(void) _close(fd);
Modified: projects/collation/lib/libc/locale/setrunelocale.c
==============================================================================
--- projects/collation/lib/libc/locale/setrunelocale.c Sun Aug 9 11:50:50 2015 (r286521)
+++ projects/collation/lib/libc/locale/setrunelocale.c Sun Aug 9 12:13:30 2015 (r286522)
@@ -97,7 +97,7 @@ __setrunelocale(struct xlocale_ctype *l,
{
_RuneLocale *rl;
int ret;
- char path[PATH_MAX];
+ char *path;
struct xlocale_ctype saved = *l;
/*
@@ -110,13 +110,16 @@ __setrunelocale(struct xlocale_ctype *l,
}
/* Range checking not needed, encoding length already checked before */
- (void) snprintf(path, sizeof (path), "%s/%s/LC_CTYPE",
- _PathLocale, encoding);
+ asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding);
+ if (path == NULL)
+ return (0);
if ((rl = _Read_RuneMagi(path)) == NULL) {
+ free(path);
errno = EINVAL;
return (errno);
}
+ free(path);
l->__mbrtowc = NULL;
l->__mbsinit = NULL;
More information about the svn-src-projects
mailing list