diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index a2379da335..01abd2adae 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -1044,7 +1044,7 @@ gst_rtp_buffer_set_timestamp (GstRTPBuffer * rtp, guint32 timestamp) * * Create a subbuffer of the payload of the RTP packet in @buffer. @offset bytes * are skipped in the payload and the subbuffer will be of size @len. - * If @len is -1 the total payload starting from @offset if subbuffered. + * If @len is -1 the total payload starting from @offset is subbuffered. * * Returns: A new buffer with the specified data of the payload. */ @@ -1056,7 +1056,7 @@ gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer * rtp, guint offset, plen = gst_rtp_buffer_get_payload_len (rtp); /* we can't go past the length */ - if (G_UNLIKELY (offset >= plen)) + if (G_UNLIKELY (offset > plen)) goto wrong_offset; /* apply offset */ @@ -1073,7 +1073,7 @@ gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer * rtp, guint offset, /* ERRORS */ wrong_offset: { - g_warning ("offset=%u should be less then plen=%u", offset, plen); + g_warning ("offset=%u should be less than plen=%u", offset, plen); return NULL; } } diff --git a/tests/check/libs/rtp.c b/tests/check/libs/rtp.c index 9d57dbda50..601200d56f 100644 --- a/tests/check/libs/rtp.c +++ b/tests/check/libs/rtp.c @@ -955,6 +955,24 @@ GST_START_TEST (test_rtp_buffer_get_payload_bytes) GST_END_TEST; + +GST_START_TEST (test_rtp_buffer_empty_payload) +{ + GstRTPBuffer rtp = { NULL }; + GstBuffer *paybuf, *outbuf; + + paybuf = gst_rtp_buffer_new_allocate (0, 0, 0); + + gst_rtp_buffer_map (paybuf, GST_MAP_READ, &rtp); + outbuf = gst_rtp_buffer_get_payload_buffer (&rtp); + gst_rtp_buffer_unmap (&rtp); + + gst_buffer_unref (paybuf); + gst_buffer_unref (outbuf); +} + +GST_END_TEST; + static Suite * rtp_suite (void) { @@ -974,6 +992,7 @@ rtp_suite (void) tcase_add_test (tc_chain, test_rtp_buffer_get_payload_bytes); tcase_add_test (tc_chain, test_rtp_buffer_get_extension_bytes); + tcase_add_test (tc_chain, test_rtp_buffer_empty_payload); //tcase_add_test (tc_chain, test_rtp_buffer_list);