mirror of git://sourceware.org/git/glibc.git
Sun Jun 2 20:14:30 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* locale/programs/linereader.c (lr_open): Don't pass NULL to xstrdup; fix memory leak. (lr_close): Fix memory leak.
This commit is contained in:
parent
9f195df2d7
commit
20328c3962
|
@ -66,7 +66,7 @@ lr_open (const char *fname, kw_hash_fct_t hf)
|
||||||
result = (struct linereader *) xmalloc (sizeof (*result));
|
result = (struct linereader *) xmalloc (sizeof (*result));
|
||||||
|
|
||||||
result->fp = fp;
|
result->fp = fp;
|
||||||
result->fname = xstrdup (fname);
|
result->fname = xstrdup (fname ? : "<stdin>");
|
||||||
result->buf = NULL;
|
result->buf = NULL;
|
||||||
result->bufsize = 0;
|
result->bufsize = 0;
|
||||||
result->lineno = 1;
|
result->lineno = 1;
|
||||||
|
@ -80,6 +80,7 @@ lr_open (const char *fname, kw_hash_fct_t hf)
|
||||||
{
|
{
|
||||||
int save = errno;
|
int save = errno;
|
||||||
fclose (result->fp);
|
fclose (result->fp);
|
||||||
|
free (result->fname);
|
||||||
free (result);
|
free (result);
|
||||||
errno = save;
|
errno = save;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -107,6 +108,7 @@ void
|
||||||
lr_close (struct linereader *lr)
|
lr_close (struct linereader *lr)
|
||||||
{
|
{
|
||||||
fclose (lr->fp);
|
fclose (lr->fp);
|
||||||
|
free (lr->fname);
|
||||||
free (lr->buf);
|
free (lr->buf);
|
||||||
free (lr);
|
free (lr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue