summaryrefslogtreecommitdiffhomepage
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-22 19:02:31 -0400
committermidipix <writeonce@midipix.org>2016-05-23 04:15:23 -0400
commite64108c8293703cada52b1d9860bb3a642536bef (patch)
tree6e70272ff2184c02884e5f0240a66cd3745fb173 /src/logic
parent3643b93a2477d87b5769ebfd799942685ab1b725 (diff)
downloadslibtool-e64108c8293703cada52b1d9860bb3a642536bef.tar.bz2
slibtool-e64108c8293703cada52b1d9860bb3a642536bef.tar.xz
link mode: properly handle empty dependency files.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_link.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 4c78757..cdda42b 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -124,7 +124,11 @@ static int slbt_get_deps_meta(
depsmeta->infolen += st.st_size;
depsmeta->infolen++;
- for (deplib=fgets(deplibs,st.st_size+1,fdeps); deplib; ) {
+ deplib = st.st_size
+ ? fgets(deplibs,st.st_size+1,fdeps)
+ : 0;
+
+ for (; deplib; ) {
depsmeta->depscnt++;
deplib = fgets(deplibs,st.st_size+1,fdeps);
}
@@ -372,8 +376,9 @@ static int slbt_exec_link_adjust_argument_vector(
if (dpath) {
if (!stat(dpath,&st) && (fdeps = fopen(dpath,"r"))) {
- dep = fgets(darg,st.st_size+1,fdeps);
- *aarg = darg;
+ dep = st.st_size
+ ? fgets(darg,st.st_size+1,fdeps)
+ : 0;
for (; dep; ) {
*aarg++ = darg;
@@ -495,7 +500,11 @@ static int slbt_exec_link_create_dep_file(
if (!(fdeps = fopen(depfile,"r")))
return -1;
- for (deplib=fgets(deplibs,st.st_size+1,fdeps); deplib; ) {
+ deplib = st.st_size
+ ? fgets(deplibs,st.st_size+1,fdeps)
+ : 0;
+
+ for (; deplib; ) {
if (fprintf(ectx->fdeps,"%s",deplib) < 0) {
fclose(fdeps);
return -1;