[Ocfs2-tools-devel] [PATCH 5/5 V2] mount.ocfs2: Check if 's' is NULL before free it

piaojun piaojun at huawei.com
Tue Apr 28 17:49:22 PDT 2015


In xstrconcat3(), we should check if 's' is null before free it.

Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>

---
 mount.ocfs2/sundries.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mount.ocfs2/sundries.c b/mount.ocfs2/sundries.c
index 2e1b95a..b5efcab 100644
--- a/mount.ocfs2/sundries.c
+++ b/mount.ocfs2/sundries.c
@@ -56,7 +56,8 @@ xstrconcat3 (const char *s, const char *t, const char *u) {
      strcpy(res, s);
      strcat(res, t);
      strcat(res, u);
-     free((void *) s);
+     if (strlen(s))
+         free((void *) s);
      return res;
 }

-- 1.8.4.3




More information about the Ocfs2-tools-devel mailing list