Fix crash on empty file.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 25 Jun 2010 16:52:30 +0000 (16:52 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 25 Jun 2010 16:52:30 +0000 (16:52 +0000)
org.glite.lb.utils/src/purge.c

index db3b1c1..73cf082 100644 (file)
@@ -244,6 +244,11 @@ int main(int argc,char *argv[])
                } else {
                        dprintf(("yes.\n"));
                }
+               if (!jobs) {
+                       dprintf(("File empty.\n"));
+                       goto main_end;
+               }
+
                request->jobs = jobs;
        }
 
@@ -371,7 +376,7 @@ static int read_jobIds(const char *file, char ***jobs_out)
                }
                 jobs[cnt++] = strdup(buf);
         }
-       jobs[cnt] = NULL;
+       if (jobs) jobs[cnt] = NULL;
 
         fclose(jobIds);
        *jobs_out = jobs;