Author: vlendec Date: 2007-07-16 07:40:30 +0000 (Mon, 16 Jul 2007) New Revision: 23882
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23882 Log: Fix Coverity id 389 -- finally (I hope) Modified: branches/SAMBA_3_2/source/locking/brlock.c branches/SAMBA_3_2_0/source/locking/brlock.c Changeset: Modified: branches/SAMBA_3_2/source/locking/brlock.c =================================================================== --- branches/SAMBA_3_2/source/locking/brlock.c 2007-07-16 01:48:07 UTC (rev 23881) +++ branches/SAMBA_3_2/source/locking/brlock.c 2007-07-16 07:40:30 UTC (rev 23882) @@ -1641,14 +1641,18 @@ talloc_set_destructor(br_lck, byte_range_lock_destructor); br_lck->num_locks = data.dsize / sizeof(struct lock_struct); - br_lck->lock_data = SMB_MALLOC_ARRAY(struct lock_struct, br_lck->num_locks); - if ((br_lck->num_locks != 0) && (br_lck->lock_data == NULL)) { - DEBUG(0, ("malloc failed\n")); - TALLOC_FREE(br_lck); - return NULL; + + if (br_lck->num_locks != 0) { + br_lck->lock_data = SMB_MALLOC_ARRAY(struct lock_struct, + br_lck->num_locks); + if (br_lck->lock_data == NULL) { + DEBUG(0, ("malloc failed\n")); + TALLOC_FREE(br_lck); + return NULL; + } + + memcpy(br_lck->lock_data, data.dptr, data.dsize); } - - memcpy(br_lck->lock_data, data.dptr, data.dsize); if (!fsp->lockdb_clean) { int orig_num_locks = br_lck->num_locks; Modified: branches/SAMBA_3_2_0/source/locking/brlock.c =================================================================== --- branches/SAMBA_3_2_0/source/locking/brlock.c 2007-07-16 01:48:07 UTC (rev 23881) +++ branches/SAMBA_3_2_0/source/locking/brlock.c 2007-07-16 07:40:30 UTC (rev 23882) @@ -1641,14 +1641,18 @@ talloc_set_destructor(br_lck, byte_range_lock_destructor); br_lck->num_locks = data.dsize / sizeof(struct lock_struct); - br_lck->lock_data = SMB_MALLOC_ARRAY(struct lock_struct, br_lck->num_locks); - if ((br_lck->num_locks != 0) && (br_lck->lock_data == NULL)) { - DEBUG(0, ("malloc failed\n")); - TALLOC_FREE(br_lck); - return NULL; + + if (br_lck->num_locks != 0) { + br_lck->lock_data = SMB_MALLOC_ARRAY(struct lock_struct, + br_lck->num_locks); + if (br_lck->lock_data == NULL) { + DEBUG(0, ("malloc failed\n")); + TALLOC_FREE(br_lck); + return NULL; + } + + memcpy(br_lck->lock_data, data.dptr, data.dsize); } - - memcpy(br_lck->lock_data, data.dptr, data.dsize); if (!fsp->lockdb_clean) { int orig_num_locks = br_lck->num_locks;