Protect against dereferencing a null ptr.

'stream' may be left nullptr after a pop, so don't try to dereference
it.

(via nlewycky@google.com).
pull/3082/head
David Garcia Quintas 9 years ago
parent 4f5e6f0133
commit c9ab6a022d
  1. 44
      src/core/transport/chttp2/stream_lists.c

@ -177,8 +177,10 @@ int grpc_chttp2_list_pop_writable_stream(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_WRITABLE); GRPC_CHTTP2_LIST_WRITABLE);
*stream_global = &stream->global; if (r != 0) {
*stream_writing = &stream->writing; *stream_global = &stream->global;
*stream_writing = &stream->writing;
}
return r; return r;
} }
@ -210,7 +212,9 @@ int grpc_chttp2_list_pop_writing_stream(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream, int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream,
GRPC_CHTTP2_LIST_WRITING); GRPC_CHTTP2_LIST_WRITING);
*stream_writing = &stream->writing; if (r != 0) {
*stream_writing = &stream->writing;
}
return r; return r;
} }
@ -230,8 +234,10 @@ int grpc_chttp2_list_pop_written_stream(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream, int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream,
GRPC_CHTTP2_LIST_WRITTEN); GRPC_CHTTP2_LIST_WRITTEN);
*stream_global = &stream->global; if (r != 0) {
*stream_writing = &stream->writing; *stream_global = &stream->global;
*stream_writing = &stream->writing;
}
return r; return r;
} }
@ -251,8 +257,10 @@ int grpc_chttp2_list_pop_parsing_seen_stream(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_PARSING(transport_parsing), &stream, int r = stream_list_pop(TRANSPORT_FROM_PARSING(transport_parsing), &stream,
GRPC_CHTTP2_LIST_PARSING_SEEN); GRPC_CHTTP2_LIST_PARSING_SEEN);
*stream_global = &stream->global; if (r != 0) {
*stream_parsing = &stream->parsing; *stream_global = &stream->global;
*stream_parsing = &stream->parsing;
}
return r; return r;
} }
@ -270,7 +278,9 @@ int grpc_chttp2_list_pop_waiting_for_concurrency(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY); GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
*stream_global = &stream->global; if (r != 0) {
*stream_global = &stream->global;
}
return r; return r;
} }
@ -288,7 +298,9 @@ int grpc_chttp2_list_pop_closed_waiting_for_parsing(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING); GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING);
*stream_global = &stream->global; if (r != 0) {
*stream_global = &stream->global;
}
return r; return r;
} }
@ -306,7 +318,9 @@ int grpc_chttp2_list_pop_cancelled_waiting_for_writing(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_CANCELLED_WAITING_FOR_WRITING); GRPC_CHTTP2_LIST_CANCELLED_WAITING_FOR_WRITING);
*stream_global = &stream->global; if (r != 0) {
*stream_global = &stream->global;
}
return r; return r;
} }
@ -326,8 +340,10 @@ int grpc_chttp2_list_pop_incoming_window_updated(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED); GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED);
*stream_global = &stream->global; if (r != 0) {
*stream_parsing = &stream->parsing; *stream_global = &stream->global;
*stream_parsing = &stream->parsing;
}
return r; return r;
} }
@ -353,7 +369,9 @@ int grpc_chttp2_list_pop_read_write_state_changed(
grpc_chttp2_stream *stream; grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED); GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED);
*stream_global = &stream->global; if (r != 0) {
*stream_global = &stream->global;
}
return r; return r;
} }

Loading…
Cancel
Save