61 lines
1.6 KiB
Diff
61 lines
1.6 KiB
Diff
From 9c9034a8cb88de406c64553d27f6471f99b9e06a Mon Sep 17 00:00:00 2001
|
|
From: Florian Westphal <fw@strlen.de>
|
|
Date: Mon, 4 Mar 2019 01:06:05 +0100
|
|
Subject: [PATCH] segtree: fix crash when debug mode is active
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
We must set output_fp to sensible filep, else crash.
|
|
|
|
Reported-by: Václav Zindulka <vaclav.zindulka@tlapnet.cz>
|
|
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
(cherry picked from commit afd1ad6f68680c0f0a4afad7c67ddc8652948732)
|
|
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
---
|
|
src/segtree.c | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/segtree.c b/src/segtree.c
|
|
index 5685618b3724a..5a5a728912db7 100644
|
|
--- a/src/segtree.c
|
|
+++ b/src/segtree.c
|
|
@@ -9,6 +9,7 @@
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
+#include <string.h>
|
|
#include <inttypes.h>
|
|
#include <arpa/inet.h>
|
|
|
|
@@ -67,8 +68,6 @@ struct elementary_interval {
|
|
struct expr *expr;
|
|
};
|
|
|
|
-static struct output_ctx debug_octx = {};
|
|
-
|
|
static void seg_tree_init(struct seg_tree *tree, const struct set *set,
|
|
struct expr *init, unsigned int debug_mask)
|
|
{
|
|
@@ -570,6 +569,7 @@ int set_to_intervals(struct list_head *errs, struct set *set,
|
|
bool merge)
|
|
{
|
|
struct elementary_interval *ei, *next;
|
|
+ struct output_ctx debug_octx;
|
|
struct seg_tree tree;
|
|
LIST_HEAD(list);
|
|
|
|
@@ -590,6 +590,9 @@ int set_to_intervals(struct list_head *errs, struct set *set,
|
|
}
|
|
|
|
if (segtree_debug(tree.debug_mask)) {
|
|
+ memset(&debug_octx, 0, sizeof(debug_octx));
|
|
+ debug_octx.output_fp = stderr;
|
|
+ debug_octx.error_fp = stderr;
|
|
expr_print(init, &debug_octx);
|
|
pr_gmp_debug("\n");
|
|
}
|
|
--
|
|
2.21.0
|
|
|