From 758da4f3b4d71e9dabd8b5fb3b79b6a58d46e47a Mon Sep 17 00:00:00 2001 From: gogolovefish <64474767+gogolovefish@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:35:13 +0800 Subject: [PATCH] After release the pointer, assign NULL value Signed-off-by: wanhui --- libselinux/src/context.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libselinux/src/context.c b/libselinux/src/context.c index 33c48ef3d7..8514efb580 100644 --- a/libselinux/src/context.c +++ b/libselinux/src/context.c @@ -28,10 +28,12 @@ context_t context_new(const char *str) context_t result = (context_t) malloc(sizeof(context_s_t)); const char *p, *tok; - if (result) + if (result){ result->ptr = n; - else + }else{ free(n); + n=NULL; + } if (n == 0 || result == 0) { goto err; }