From: Jim Meyering <jim@meyering.net>
To: dash@vger.kernel.org
Subject: [PATCH] setvareq: do not return a freed pointer
Date: Sun, 19 Jun 2011 21:30:41 +0200 [thread overview]
Message-ID: <8739j5aaam.fsf@rho.meyering.net> (raw)
This change may be technically unnecessary, but it's worth
the minuscule cost of the initialization.
2011-06-19 Jim Meyering <meyering@redhat.com>
setvareq: do not return a freed pointer
* src/var.c (setvareq): Don't return a freed pointer.
In at least one case (when called from unsetvar), the return
value is not used, but better not to risk it, and to placate
static analyzers. Spotted by coverity.
Exercise via dash -c 'j=; unset j'
From e91caa66e9f1e449e5ea129d2c1e304e66784e2f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sun, 19 Jun 2011 21:28:02 +0200
Subject: [PATCH] setvareq: do not return a freed pointer
* src/var.c (setvareq): Don't return a freed pointer.
In at least one case (when called from unsetvar), the return
value is not used, but better not to risk it, and to placate
static analyzers. Spotted by coverity.
Exercise via dash -c 'j=; unset j'
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
ChangeLog | 9 +++++++++
src/var.c | 1 +
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/var.c b/src/var.c
index ecc8c90..34c5d32 100644
--- a/src/var.c
+++ b/src/var.c
@@ -276,6 +276,7 @@ struct var *setvareq(char *s, int flags)
(vp->flags & VSTRFIXED)) == VUNSET) {
*vpp = vp->next;
ckfree(vp);
+ vp = NULL;
out_free:
if ((flags & (VTEXTFIXED|VSTACK|VNOSAVE)) == VNOSAVE)
ckfree(s);
--
1.7.6.rc2.4.g36bfb.dirty
next reply other threads:[~2011-06-19 19:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-19 19:30 Jim Meyering [this message]
2011-07-08 8:57 ` [PATCH] setvareq: do not return a freed pointer Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8739j5aaam.fsf@rho.meyering.net \
--to=jim@meyering.net \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox