From d85c2b79e5df6390c88d74c014960897847b27c7 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Thu, 7 Mar 2019 12:43:37 -0700 Subject: [PATCH] fixed memory leak --- src/clib/pioc_sc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/clib/pioc_sc.c b/src/clib/pioc_sc.c index 0648264eeeb..49a36848224 100644 --- a/src/clib/pioc_sc.c +++ b/src/clib/pioc_sc.c @@ -150,12 +150,6 @@ PIO_Offset GCDblocksize(int arrlen, const PIO_Offset *arr_in) /* Check inputs. */ pioassert(arrlen > 0 && arr_in, "invalid input", __FILE__, __LINE__); - /* Allocate arrays. */ - if (!(loc_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1)))) - return PIO_ENOMEM; - if (!(del_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1)))) - return PIO_ENOMEM; - /* Count the number of contiguous blocks in arr_in. If any if these blocks is of size 1, we are done and can return. Otherwise numtimes is the number of blocks. */ @@ -170,6 +164,12 @@ PIO_Offset GCDblocksize(int arrlen, const PIO_Offset *arr_in) } } + /* Allocate arrays. */ + if (!(loc_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1)))) + return PIO_ENOMEM; + if (!(del_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1)))) + return PIO_ENOMEM; + /* If numtimes is 0 the all of the data in arr_in is contiguous * and numblks=1. Not sure why I have three different variables * here, seems like n,numblks and numtimes could be combined. */