Use buffer instead of line in read_config_file(), line may be assigned
NULL, so buffer always holds the pointer to the allocated space.
This commit is contained in:
parent
ab33c1aa60
commit
52575a573c
1 changed files with 5 additions and 5 deletions
10
src/conf.c
10
src/conf.c
|
@ -19,7 +19,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id: conf.c,v 1.9.4.30 2000/12/01 12:36:36 zarq Exp $
|
$Id: conf.c,v 1.9.4.31 2000/12/01 12:38:42 zarq Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -218,7 +218,7 @@ int read_config_file(config_t **base, const char *fname)
|
||||||
{
|
{
|
||||||
int err = -1;
|
int err = -1;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *line;
|
char *buffer, *line;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int i, lineno = 0;
|
int i, lineno = 0;
|
||||||
config_t *cfg;
|
config_t *cfg;
|
||||||
|
@ -229,11 +229,11 @@ cp
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
bufsize = 100;
|
bufsize = 100;
|
||||||
line = xmalloc(bufsize);
|
buffer = xmalloc(bufsize);
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if((line = readline(fp, line, &bufsize)) == NULL)
|
if((line = readline(fp, buffer, &bufsize)) == NULL)
|
||||||
{
|
{
|
||||||
err = -1;
|
err = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -284,7 +284,7 @@ cp
|
||||||
config = cfg;
|
config = cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(line);
|
free(buffer);
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
cp
|
cp
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in a new issue