diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 94b07753..47ca79a5 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -2879,8 +2879,8 @@ NGHTTP2_EXTERN int nghttp2_session_consume_stream(nghttp2_session *session, * :enum:`NGHTTP2_ERR_NOMEM` * Out of memory. * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` - * Attempted to depend on itself; no stream exist for the given - * |stream_id|. + * Attempted to depend on itself; or no stream exist for the given + * |stream_id|; or |stream_id| is 0 */ NGHTTP2_EXTERN int nghttp2_session_change_stream_priority(nghttp2_session *session, diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 7f1e883e..473b3807 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -6789,7 +6789,7 @@ int nghttp2_session_change_stream_priority( nghttp2_stream *stream; nghttp2_priority_spec pri_spec_copy; - if (stream_id == pri_spec->stream_id) { + if (stream_id == 0 || stream_id == pri_spec->stream_id) { return NGHTTP2_ERR_INVALID_ARGUMENT; } diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 3b85e743..45f61d33 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -8379,6 +8379,10 @@ void test_nghttp2_session_change_stream_priority(void) { rv = nghttp2_session_change_stream_priority(session, 1, &pri_spec); CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + /* It is an error to change priority of root stream (0) */ + rv = nghttp2_session_change_stream_priority(session, 0, &pri_spec); + CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == rv); + nghttp2_session_del(session); }