Use more asprintf
Plug memory leak introduced in previous asprintf addition
This commit is contained in:
parent
b89704cee7
commit
28a20bb3f5
@ -124,8 +124,10 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
|
||||
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);
|
||||
|
@ -97,7 +97,7 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding)
|
||||
{
|
||||
_RuneLocale *rl;
|
||||
int ret;
|
||||
char path[PATH_MAX];
|
||||
char *path;
|
||||
struct xlocale_ctype saved = *l;
|
||||
|
||||
/*
|
||||
@ -110,13 +110,16 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user