Skip to content
Snippets Groups Projects
Commit a4d2afff authored by rswindell's avatar rswindell
Browse files

Added NULL fp checking str_list_read_file().

parent 039aee69
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -373,14 +373,16 @@ static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_l
lp=&list;
}
count=strListCount(*lp);
while(!feof(fp)) {
if(buf==NULL && (buf=(char*)alloca(max_line_len+1))==NULL)
return(NULL);
if(fgets(buf,max_line_len+1,fp)==NULL)
break;
strListAppend(lp, buf, count++);
if(fp!=NULL) {
count=strListCount(*lp);
while(!feof(fp)) {
if(buf==NULL && (buf=(char*)alloca(max_line_len+1))==NULL)
return(NULL);
if(fgets(buf,max_line_len+1,fp)==NULL)
break;
strListAppend(lp, buf, count++);
}
}
return(*lp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment