From 990eb2e016b21f3bebf12acde7e30b81f9d1f2e8 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Thu, 13 Apr 2017 14:17:31 -0600 Subject: [PATCH] Make it so if xmalloc returns NULL we still get a size in the perl api. This changed in 17.11 where if the size was 0 we would return 0 which messes up the perl api. Bug 3644 --- NEWS | 1 + contribs/perlapi/libslurm/perl/Slurm.xs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fe5f6757033..88c3b7f45f9 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ documents those changes that are of interest to users and administrators. -- When running the "scontrol top" command, make sure that all of the user's jobs have a priority that is lower than the selected job. Previous logic would permit other jobs with equal priority (no jobs with higher priority). + -- Fix perl api so we always get an allocation when calling Slurm::new(). * Changes in Slurm 17.02.2 ========================== diff --git a/contribs/perlapi/libslurm/perl/Slurm.xs b/contribs/perlapi/libslurm/perl/Slurm.xs index 7bda2050d6a..27c702ab60c 100644 --- a/contribs/perlapi/libslurm/perl/Slurm.xs +++ b/contribs/perlapi/libslurm/perl/Slurm.xs @@ -30,7 +30,12 @@ static struct slurm default_slurm_object; static slurm_t new_slurm(void) { - return xmalloc(sizeof(struct slurm)); + int size = sizeof(struct slurm); + if (size == 0) { + /* Avoid returning NULL, which causes the perl APIs to fail */ + size = 1; + } + return xmalloc(size); } static void -- GitLab