From 8d497e575c85979c7107a0a1efd6bc75ac1d391f Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 31 Mar 2012 14:37:04 -0400 Subject: [PATCH] bucoord: Don't malloc(0) if there's no work to do If there's no work to do, then don't attempt to malloc 0 bytes, and just return success to the user Change-Id: I060852a247acb8309c75f3670577561b5a9af591 Reviewed-on: http://gerrit.openafs.org/7099 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/bucoord/dump.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bucoord/dump.c b/src/bucoord/dump.c index 3c67a7fc3..5d1f58aa3 100644 --- a/src/bucoord/dump.c +++ b/src/bucoord/dump.c @@ -51,7 +51,7 @@ bc_Dumper(int aindex) struct rx_connection *tconn; struct bc_volumeDump *tde; afs_int32 count, port; - struct tc_dumpDesc *volDesc = 0; + struct tc_dumpDesc *volDesc = NULL; struct tc_dumpArray volArray; char *baseNamePtr; statusP statusPtr; @@ -78,8 +78,12 @@ bc_Dumper(int aindex) */ for (count = 0, tde = dumpTaskPtr->volumes; tde; tde = tde->next, count++); - volDesc = - (struct tc_dumpDesc *)malloc(count * sizeof(struct tc_dumpDesc)); + + /* Nothing to dump, so just return success */ + if (count == 0) + goto error_exit; + + volDesc = malloc(count * sizeof(struct tc_dumpDesc)); if (!volDesc) { afs_com_err(whoami, BC_NOMEM, NULL); ERROR(BC_NOMEM); -- 2.39.5