From: Simon Wilkinson Date: Sat, 31 Mar 2012 18:37:04 +0000 (-0400) Subject: bucoord: Don't malloc(0) if there's no work to do X-Git-Tag: upstream/1.8.0_pre1^2~2593 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=8d497e575c85979c7107a0a1efd6bc75ac1d391f;p=packages%2Fo%2Fopenafs.git 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 --- 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);