Changeset fcbf24b4e9cd444703948eb6d36da763a7e641f5
- Timestamp:
- 01/03/08 19:20:01
(9 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1204395601 +0000
- git-parent:
[80af71f72f1ac98a372f8a75ebca09d3430c7192]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1204395601 +0000
- Message:
Check some malloc() failures - yes it can happen when the alloc size is variable. Unfortunately, the MP4 code seems pretty hopeless.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r80af71f |
rfcbf24b |
|
| 69 | 69 | const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 ); \ |
|---|
| 70 | 70 | p_str = malloc( __i_copy__+1 ); \ |
|---|
| 71 | | if( __i_copy__ > 0 ) memcpy( p_str, p_peek, __i_copy__ ); \ |
|---|
| 72 | | p_str[__i_copy__] = 0; \ |
|---|
| | 71 | if( p_str ) \ |
|---|
| | 72 | { \ |
|---|
| | 73 | memcpy( p_str, p_peek, __i_copy__ ); \ |
|---|
| | 74 | p_str[__i_copy__] = 0; \ |
|---|
| | 75 | } \ |
|---|
| 73 | 76 | p_peek += __i_copy__ + 1; \ |
|---|
| 74 | 77 | i_read -= __i_copy__ + 1; \ |
|---|
| … | … | |
| 589 | 592 | { |
|---|
| 590 | 593 | int32_t i_reserved; |
|---|
| | 594 | int code = 0; |
|---|
| 591 | 595 | |
|---|
| 592 | 596 | MP4_READBOX_ENTER( MP4_Box_data_hdlr_t ); |
|---|
| … | … | |
| 604 | 608 | if( i_read > 0 ) |
|---|
| 605 | 609 | { |
|---|
| 606 | | p_box->data.p_hdlr->psz_name = malloc( i_read + 1 ); |
|---|
| | 610 | uint8_t *psz = p_box->data.p_hdlr->psz_name = malloc( i_read + 1 ); |
|---|
| | 611 | if( psz == NULL ) |
|---|
| | 612 | goto error; |
|---|
| 607 | 613 | |
|---|
| 608 | 614 | /* Yes, I love .mp4 :( */ |
|---|
| … | … | |
| 615 | 621 | i_copy = __MIN( i_read, i_len ); |
|---|
| 616 | 622 | |
|---|
| 617 | | memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_copy ); |
|---|
| | 623 | memcpy( psz, p_peek, i_copy ); |
|---|
| 618 | 624 | p_box->data.p_hdlr->psz_name[i_copy] = '\0'; |
|---|
| 619 | 625 | } |
|---|
| 620 | 626 | else |
|---|
| 621 | 627 | { |
|---|
| 622 | | memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read ); |
|---|
| | 628 | memcpy( psz, p_peek, i_read ); |
|---|
| 623 | 629 | p_box->data.p_hdlr->psz_name[i_read] = '\0'; |
|---|
| 624 | 630 | } |
|---|
| … | … | |
| 631 | 637 | |
|---|
| 632 | 638 | #endif |
|---|
| 633 | | MP4_READBOX_EXIT( 1 ); |
|---|
| | 639 | code = 1; |
|---|
| | 640 | |
|---|
| | 641 | error: |
|---|
| | 642 | MP4_READBOX_EXIT( code ); |
|---|
| 634 | 643 | } |
|---|
| 635 | 644 | |
|---|
| … | … | |
| 892 | 901 | MP4_GET1BYTE( i_len ); |
|---|
| 893 | 902 | es_descriptor.psz_URL = malloc( i_len + 1 ); |
|---|
| 894 | | memcpy( es_descriptor.psz_URL, p_peek, i_len ); |
|---|
| 895 | | es_descriptor.psz_URL[i_len] = 0; |
|---|
| | 903 | if( es_descriptor.psz_URL ) |
|---|
| | 904 | { |
|---|
| | 905 | memcpy( es_descriptor.psz_URL, p_peek, i_len ); |
|---|
| | 906 | es_descriptor.psz_URL[i_len] = 0; |
|---|
| | 907 | } |
|---|
| 896 | 908 | p_peek += i_len; |
|---|
| 897 | 909 | i_read -= i_len; |
|---|
| … | … | |
| 948 | 960 | es_descriptor.p_decConfigDescr->i_decoder_specific_info_len = i_len; |
|---|
| 949 | 961 | es_descriptor.p_decConfigDescr->p_decoder_specific_info = malloc( i_len ); |
|---|
| 950 | | memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info, |
|---|
| 951 | | p_peek, i_len ); |
|---|
| | 962 | if( es_descriptor.p_decConfigDescr->p_decoder_specific_info ) |
|---|
| | 963 | memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info, |
|---|
| | 964 | p_peek, i_len ); |
|---|
| 952 | 965 | |
|---|
| 953 | 966 | MP4_READBOX_EXIT( 1 ); |
|---|
| … | … | |
| 977 | 990 | if( p_avcC->i_avcC > 0 ) |
|---|
| 978 | 991 | { |
|---|
| 979 | | p_avcC->p_avcC = malloc( p_avcC->i_avcC ); |
|---|
| 980 | | memcpy( p_avcC->p_avcC, p_peek, i_read ); |
|---|
| | 992 | uint8_t * p = p_avcC->p_avcC = malloc( p_avcC->i_avcC ); |
|---|
| | 993 | if( p ) |
|---|
| | 994 | memcpy( p, p_peek, i_read ); |
|---|
| 981 | 995 | } |
|---|
| 982 | 996 | |
|---|