From: Garrett Wollman Date: Wed, 25 Jul 2012 04:22:10 +0000 (-0400) Subject: afsdump_extract: clarify logic to avoid freeing local buffer X-Git-Tag: upstream/1.8.0_pre1^2~2146 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ff217dec93c9b46a2f161bea5439d5a41337bf51;p=packages%2Fo%2Fopenafs.git afsdump_extract: clarify logic to avoid freeing local buffer Sometimes vnodepath is set to a local buffer. Sometimes it is set to malloc'ed storage. Simplify the logic for freeing vnodepath by checking explicitly for this condition rather than the state of other variables. As a bonus, avoids a false (?) positive from the static analyzer. Change-Id: I3772cb97698acc5a6ac1f438977c673e6fea7722 Reviewed-on: http://gerrit.openafs.org/7869 Tested-by: BuildBot Reviewed-by: Simon Wilkinson Reviewed-by: Alistair Ferguson Reviewed-by: Derrick Brashear --- diff --git a/src/tools/dumpscan/afsdump_extract.c b/src/tools/dumpscan/afsdump_extract.c index 4a17557d8..dec8dc848 100644 --- a/src/tools/dumpscan/afsdump_extract.c +++ b/src/tools/dumpscan/afsdump_extract.c @@ -437,7 +437,7 @@ file_cb(afs_vnode * v, XFILE * X, void *refcon) || (r = xfopen_path(&OX, O_RDWR | O_CREAT | O_TRUNC, vnodepath + 1, 0644))) { - if (!use_vnum) + if (vnodepath != vnpx) free(vnodepath); return r; } @@ -447,7 +447,7 @@ file_cb(afs_vnode * v, XFILE * X, void *refcon) } else r = 0; - if (!use_vnum && use != 2) + if (vnodepath != vnpx) free(vnodepath); return r; } @@ -485,14 +485,14 @@ symlink_cb(afs_vnode * v, XFILE * X, void *refcon) } if (!(linktarget = malloc(v->size + 1))) { - if (!use_vnum && use != 2) + if (vnodepath != vnpx) free(vnodepath); return DSERR_MEM; } if ((r = xftell(X, &where)) || (r = xfseek(X, &v->d_offset)) || (r = xfread(X, linktarget, v->size))) { - if (!use_vnum && use != 2) + if (vnodepath != vnpx) free(vnodepath); free(linktarget); return r; @@ -515,7 +515,7 @@ symlink_cb(afs_vnode * v, XFILE * X, void *refcon) } free(linktarget); - if (!use_vnum && use != 2) + if (vnodepath != vnpx) free(vnodepath); return r; }