From: Garrett Wollman Date: Sat, 13 Aug 2011 23:01:26 +0000 (-0400) Subject: libafs: don't free a null pointer in an unlikely error condition X-Git-Tag: openafs-devel-1_7_1~142 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=5c0e92a159f11366a88adab4700e3f909124a06a libafs: don't free a null pointer in an unlikely error condition It is extremely unlikely that we will ever fail to allocate two bytes in SRXAFSCB_GetCellServDB() to hold the empty-string return value for the case where the specified cell can't be found. But that would result in freeing a null pointer, so check for it. Change-Id: I47a296148e231b0ef20ecd18b8458b912f22a58c Found-by: clang static analyzer with the help of AFS_NONNULL Reviewed-on: http://gerrit.openafs.org/5261 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index b880979..c2d36a1 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -1304,7 +1304,8 @@ SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, t_name = afs_osi_Alloc(i + 1); if (t_name == NULL) { - afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32))); + if (tcell != NULL) + afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32))); RX_AFS_GUNLOCK(); return ENOMEM; }