Catching invalid njs_mp_free() calls.
diff --git a/auto/options b/auto/options
index 3590d22..5b6d638 100644
--- a/auto/options
+++ b/auto/options
@@ -62,3 +62,7 @@
NJS_CONFIGURE_OPTIONS="$NJS_CONFIGURE_OPTIONS $njs_opt"
done
+
+if [ "$NJS_DEBUG_MEMORY" = "YES" ]; then
+ NJS_DEBUG=YES
+fi
diff --git a/src/njs_assert.h b/src/njs_assert.h
index 55583ca..c4de79b 100644
--- a/src/njs_assert.h
+++ b/src/njs_assert.h
@@ -18,9 +18,19 @@
} \
} while (0)
+#define njs_assert_msg(condition, fmt, ...) \
+ do { \
+ if (!(condition)) { \
+ njs_stderror(fmt, ##__VA_ARGS__); \
+ njs_stderror(" at %s:%d\n", __FILE__, __LINE__); \
+ abort(); \
+ } \
+ } while (0)
+
#else
#define njs_assert(condition) (void) (condition)
+#define njs_assert_msg(condition, fmt, ...) (void) (condition)
#endif
diff --git a/src/njs_mp.c b/src/njs_mp.c
index 5c7868d..27b2463 100644
--- a/src/njs_mp.c
+++ b/src/njs_mp.c
@@ -678,14 +678,12 @@
return;
} else {
- err = "freed pointer points to middle of block: %p\n";
+ njs_assert_msg(0, "freed pointer points to middle of blk: %p\n", p);
}
} else {
- err = "freed pointer is out of mp: %p\n";
+ njs_assert_msg(0, "freed pointer is out of mp: %p\n", p);
}
-
- njs_debug_alloc(err, p);
}