[PATCH 06/19] Removed bad frees from nfs/xcommon.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



nfs/xcommon.c:63: incorrect_free: "free" frees incorrect pointer "(void *)s".
nfs/xcommon.c:81: incorrect_free: "free" frees incorrect pointer "(void *)s".

Signed-off-by: Steve Dickson <steved@xxxxxxxxxx>
---
 support/nfs/xcommon.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
index 14e580e..3989f0b 100644
--- a/support/nfs/xcommon.c
+++ b/support/nfs/xcommon.c
@@ -53,14 +53,17 @@ char *
 xstrconcat3 (const char *s, const char *t, const char *u) {
      char *res;
 
-     if (!s) s = "";
+     int dofree = 1;
+
+     if (!s) s = "", dofree=0;
      if (!t) t = "";
      if (!u) u = "";
      res = xmalloc(strlen(s) + strlen(t) + strlen(u) + 1);
      strcpy(res, s);
      strcat(res, t);
      strcat(res, u);
-     free((void *) s);
+     if (dofree)
+         free((void *) s);
      return res;
 }
 
@@ -69,7 +72,9 @@ char *
 xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {
      char *res;
 
-     if (!s) s = "";
+     int dofree = 1;
+
+     if (!s) s = "", dofree=0;
      if (!t) t = "";
      if (!u) u = "";
      if (!v) v = "";
@@ -78,7 +83,8 @@ xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {
      strcat(res, t);
      strcat(res, u);
      strcat(res, v);
-     free((void *) s);
+     if (dofree)
+         free((void *) s);
      return res;
 }
 
-- 
2.20.1




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux