]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: cm_BPlusEnumAlloc should not fail for zero entries
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 5 Dec 2009 15:51:27 +0000 (10:51 -0500)
committerJeffrey Altman <jaltman|account-1000011@unknown>
Tue, 8 Dec 2009 14:34:00 +0000 (06:34 -0800)
If cm_BPlusEnumAlloc returns NULL, the caller assumes a
memory allocation error.  If the enumeration consists of
zero entries, allocate a structure that stores zero entries.

LICENSE MIT

Change-Id: I8ed3811a1b3a0e4262749e110027c5d5812338b6
Reviewed-on: http://gerrit.openafs.org/892
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
src/WINNT/afsd/cm_btree.c

index 2ae7c0ce312a4e1f00b5768fd0257f6e89b767b0..58dee1425a9e6e8f3796bbeb18be1a873e2b4c10 100644 (file)
@@ -2160,9 +2160,9 @@ cm_BPlusEnumAlloc(afs_uint32 entries)
     size_t        size;
 
     if (entries == 0)
-       return NULL;
-
-    size = sizeof(cm_direnum_t)+(entries-1)*sizeof(cm_direnum_entry_t);
+        size = sizeof(cm_direnum_t);
+    else
+        size = sizeof(cm_direnum_t)+(entries-1)*sizeof(cm_direnum_entry_t);
     enump = (cm_direnum_t *)malloc(size);
     memset(enump, 0, size);
     enump->count = entries;