rtpdec_h264: Check the return value of functions doing allocations
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
6451c8853a
commit
9aba0a6f7b
@ -190,7 +190,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 0: // undefined, but pass them through
|
case 0: // undefined, but pass them through
|
||||||
case 1:
|
case 1:
|
||||||
av_new_packet(pkt, len + sizeof(start_sequence));
|
if ((result = av_new_packet(pkt, len + sizeof(start_sequence))) < 0)
|
||||||
|
return result;
|
||||||
memcpy(pkt->data, start_sequence, sizeof(start_sequence));
|
memcpy(pkt->data, start_sequence, sizeof(start_sequence));
|
||||||
memcpy(pkt->data + sizeof(start_sequence), buf, len);
|
memcpy(pkt->data + sizeof(start_sequence), buf, len);
|
||||||
COUNT_NAL_TYPE(data, nal);
|
COUNT_NAL_TYPE(data, nal);
|
||||||
@ -247,7 +248,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
|||||||
if (pass == 0) {
|
if (pass == 0) {
|
||||||
/* now we know the total size of the packet (with the
|
/* now we know the total size of the packet (with the
|
||||||
* start sequences added) */
|
* start sequences added) */
|
||||||
av_new_packet(pkt, total_length);
|
if ((result = av_new_packet(pkt, total_length)) < 0)
|
||||||
|
return result;
|
||||||
dst = pkt->data;
|
dst = pkt->data;
|
||||||
} else {
|
} else {
|
||||||
assert(dst - pkt->data == total_length);
|
assert(dst - pkt->data == total_length);
|
||||||
@ -292,12 +294,14 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
|||||||
COUNT_NAL_TYPE(data, nal_type);
|
COUNT_NAL_TYPE(data, nal_type);
|
||||||
if (start_bit) {
|
if (start_bit) {
|
||||||
/* copy in the start sequence, and the reconstructed nal */
|
/* copy in the start sequence, and the reconstructed nal */
|
||||||
av_new_packet(pkt, sizeof(start_sequence) + sizeof(nal) + len);
|
if ((result = av_new_packet(pkt, sizeof(start_sequence) + sizeof(nal) + len)) < 0)
|
||||||
|
return result;
|
||||||
memcpy(pkt->data, start_sequence, sizeof(start_sequence));
|
memcpy(pkt->data, start_sequence, sizeof(start_sequence));
|
||||||
pkt->data[sizeof(start_sequence)] = reconstructed_nal;
|
pkt->data[sizeof(start_sequence)] = reconstructed_nal;
|
||||||
memcpy(pkt->data + sizeof(start_sequence) + sizeof(nal), buf, len);
|
memcpy(pkt->data + sizeof(start_sequence) + sizeof(nal), buf, len);
|
||||||
} else {
|
} else {
|
||||||
av_new_packet(pkt, len);
|
if ((result = av_new_packet(pkt, len)) < 0)
|
||||||
|
return result;
|
||||||
memcpy(pkt->data, buf, len);
|
memcpy(pkt->data, buf, len);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user