summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-03-04 01:06:05 +0100
committerFlorian Westphal <fw@strlen.de>2019-03-04 01:15:42 +0100
commitafd1ad6f68680c0f0a4afad7c67ddc8652948732 (patch)
treeb9615b0a6faf9e19561a00e571437210865d17e4 /src
parentf9d7266f88183e1dd310d38ae6cfa2a383f3619d (diff)
segtree: fix crash when debug mode is active
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>
Diffstat (limited to 'src')
-rw-r--r--src/segtree.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/segtree.c b/src/segtree.c
index e5dfd413..e3a2f48c 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");
}