diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md
index bfb95dd41..36e815e91 100644
--- a/trunk/doc/CHANGELOG.md
+++ b/trunk/doc/CHANGELOG.md
@@ -7,6 +7,7 @@ The changelog for SRS.
## SRS 7.0 Changelog
+* v7.0, 2025-08-12, Merge [#4301](https://github.com/ossrs/srs/pull/4301): Valgrind: Return error for unsupported check=new on Valgrind < 3.21. v7.0.52 (#4301)
* v7.0, 2025-08-12, Merge [#4431](https://github.com/ossrs/srs/pull/4431): fix srt cmake 4.x compiling error. v7.0.52 (#4431)
* v7.0, 2025-08-11, Merge [#4433](https://github.com/ossrs/srs/pull/4433): Use clang format. v7.0.52 (#4433)
* v7.0, 2025-08-11, Merge [#4159](https://github.com/ossrs/srs/pull/4159): Feature: Support HLS with fmp4 segment for HEVC/LLHLS. v7.0.51 (#4159)
diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp
index e2b1382ca..45a111694 100644
--- a/trunk/src/app/srs_app_http_api.cpp
+++ b/trunk/src/app/srs_app_http_api.cpp
@@ -1118,13 +1118,6 @@ srs_error_t SrsGoApiValgrind::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMess
{
srs_error_t err = srs_success;
- if (!trd_) {
- trd_ = new SrsSTCoroutine("valgrind", this, _srs_context->get_id());
- if ((err = trd_->start()) != srs_success) {
- return srs_error_wrap(err, "start");
- }
- }
-
string check = r->query_get("check");
srs_trace("query check=%s", check.c_str());
@@ -1134,6 +1127,22 @@ srs_error_t SrsGoApiValgrind::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMess
check = "full";
}
+ // Check if 'new' leak check is supported in current Valgrind version
+ if (check == "new") {
+#if !defined(VALGRIND_DO_NEW_LEAK_CHECK)
+ return srs_error_new(ERROR_NOT_SUPPORTED,
+ "valgrind?check=new requires Valgrind 3.21+, current version is %d.%d",
+ __VALGRIND_MAJOR__, __VALGRIND_MINOR__);
+#endif
+ }
+
+ if (!trd_) {
+ trd_ = new SrsSTCoroutine("valgrind", this, _srs_context->get_id());
+ if ((err = trd_->start()) != srs_success) {
+ return srs_error_wrap(err, "start");
+ }
+ }
+
// By default, response the json style response.
SrsUniquePtr obj(SrsJsonAny::object());
diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp
index dee33553e..bff4a6edd 100644
--- a/trunk/src/kernel/srs_kernel_error.hpp
+++ b/trunk/src/kernel/srs_kernel_error.hpp
@@ -109,7 +109,8 @@
XX(ERROR_SYSTEM_FILE_SETVBUF, 1096, "FileSetVBuf", "Failed to set file vbuf") \
XX(ERROR_NO_SOURCE, 1097, "NoSource", "No source found") \
XX(ERROR_STREAM_DISPOSING, 1098, "StreamDisposing", "Stream is disposing") \
- XX(ERROR_NOT_IMPLEMENTED, 1099, "NotImplemented", "Feature is not implemented")
+ XX(ERROR_NOT_IMPLEMENTED, 1099, "NotImplemented", "Feature is not implemented") \
+ XX(ERROR_NOT_SUPPORTED, 1100, "NotSupported", "Feature is not supported")
/**************************************************/
/* RTMP protocol error. */