Source-Changes-HG archive

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

[src/trunk]: src/bin/sh PR bin/52348



details:   https://anonhg.NetBSD.org/src/rev/8fa990b2f825
branches:  trunk
changeset: 825596:8fa990b2f825
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Jul 24 12:35:12 2017 +0000

description:
PR bin/52348

Avoid a reference after free (detected by asan) - harmless here, but
easy to fix.

diffstat:

 bin/sh/error.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r c834abb2774f -r 8fa990b2f825 bin/sh/error.c
--- a/bin/sh/error.c    Mon Jul 24 12:34:45 2017 +0000
+++ b/bin/sh/error.c    Mon Jul 24 12:35:12 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: error.c,v 1.40 2017/07/05 20:00:27 kre Exp $   */
+/*     $NetBSD: error.c,v 1.41 2017/07/24 12:35:12 kre Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)error.c    8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: error.c,v 1.40 2017/07/05 20:00:27 kre Exp $");
+__RCSID("$NetBSD: error.c,v 1.41 2017/07/24 12:35:12 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,7 +129,8 @@
         *      printf '%d %d %d\n' 1 a 2
         * both generate sensible text when stdout and stderr are merged.
         */
-       if (output.nextc != output.buf && output.nextc[-1] == '\n')
+       if (output.buf != NULL && output.nextc != output.buf &&
+           output.nextc[-1] == '\n')
                flushout(&output);
        if (commandname)
                outfmt(&errout, "%s: ", commandname);



Home | Main Index | Thread Index | Old Index