diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c index 80725017b6c1725e9d35d5c184e99d27b3c7bab7..77841f7a1ef7cffcef790f19655301a298797ad3 100644 --- a/src/xpdev/str_list.c +++ b/src/xpdev/str_list.c @@ -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);