Explicitly treat stream_id 0 as error in nghttp2_session_change_stream_priority

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-24 22:33:06 +09:00
parent b53b1381b7
commit b08d5b1975
3 changed files with 7 additions and 3 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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);
}