From 9dea5078a66f343566723e523bf4fef5ed2855a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Fri, 25 Jun 2010 16:52:30 +0000 Subject: [PATCH] Fix crash on empty file. --- org.glite.lb.utils/src/purge.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.glite.lb.utils/src/purge.c b/org.glite.lb.utils/src/purge.c index db3b1c1..73cf082 100644 --- a/org.glite.lb.utils/src/purge.c +++ b/org.glite.lb.utils/src/purge.c @@ -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; -- 1.8.2.3