From cb228292001c6ef42c7e7f3dfb3245a93365d638 Mon Sep 17 00:00:00 2001 From: Laurentiu Nicola Date: Thu, 14 Sep 2017 12:37:34 +0300 Subject: [PATCH] Fix NULL pointer dereference in drmaa_job_ps with unknown attr --- src/drmaa/src/session.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/drmaa/src/session.c b/src/drmaa/src/session.c index f5deeddcae..2debd2cdb9 100644 --- a/src/drmaa/src/session.c +++ b/src/drmaa/src/session.c @@ -618,18 +618,19 @@ int drmaa_job_ps( const drmaa_attrib_info_t *attr; attr = attr_by_pbs_name(i->name); - switch (attr->code) - { + if (attr) + switch (attr->code) + { - case ATTR_JOB_STATE: - pbs_state = i->value[0]; - break; + case ATTR_JOB_STATE: + pbs_state = i->value[0]; + break; - case ATTR_EXIT_STATUS: - exit_status = atoi(i->value); - break; + case ATTR_EXIT_STATUS: + exit_status = atoi(i->value); + break; + } } - } if (!rc) switch (pbs_state)