gawk/Fix-small-potential-memory-leak-for-intdiv.patch
2019-09-30 10:39:14 -04:00

69 lines
1.7 KiB
Diff

From 63a31bee666a9bf9e37eda447f7742b07917dc74 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Mon, 14 Jan 2019 20:33:32 +0200
Subject: [PATCH 228/289] Fix small potential memory leak for intdiv.
---
ChangeLog | 6 ++++++
builtin.c | 4 +++-
mpfr.c | 4 +++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/builtin.c b/builtin.c
index f2d31059..3d57234b 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-2019 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -4048,11 +4048,13 @@ do_intdiv(int nargs)
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = make_number((AWKNUM) quotient);
+ unref(sub);
sub = make_string("remainder", 9);
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = make_number((AWKNUM) remainder);
+ unref(sub);
DEREF(denominator);
DEREF(numerator);
diff --git a/mpfr.c b/mpfr.c
index 8478570f..c3ba2a6a 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2012, 2013, 2015, 2017, 2018,
+ * Copyright (C) 2012, 2013, 2015, 2017, 2018, 2019,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -1265,11 +1265,13 @@ do_mpfr_intdiv(int nargs)
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = quotient;
+ unref(sub);
sub = make_string("remainder", 9);
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = remainder;
+ unref(sub);
return make_number((AWKNUM) 0.0);
}
--
2.19.1