Some of these enums have gaps in between their values, since they correspond to the values in various specs, instead of being an incrementing list. Fixes segfaults when, for example, using the valid API call: av_color_primaries_from_name("jecdec-p22");
Unified · Split
| @@ -2737,7 +2737,12 @@ int av_color_primaries_from_name(const char *name) · 2736 unmodified lines | |||
| 2737 | int i; | 2737 | int i; |
| 2738 | 2738 | ||
| 2739 | for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) { | 2739 | for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) { |
| 2740 | size_t len = strlen(color_primaries_names[i]); | 2740 | size_t len; |
| 2741 | |||
| 2742 | if (!color_primaries_names[i]) | ||
| 2743 | continue; | ||
| 2744 | |||
| 2745 | len = strlen(color_primaries_names[i]); | ||
| 2741 | if (!strncmp(color_primaries_names[i], name, len)) | 2746 | if (!strncmp(color_primaries_names[i], name, len)) |
| 2742 | return i; | 2747 | return i; |
| 2743 | } | 2748 | } |
| @@ -2756,7 +2761,12 @@ int av_color_transfer_from_name(const char *name) · 12 unmodified lines | |||
| 2756 | int i; | 2761 | int i; |
| 2757 | 2762 | ||
| 2758 | for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) { | 2763 | for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) { |
| 2759 | size_t len = strlen(color_transfer_names[i]); | 2764 | size_t len; |
| 2765 | |||
| 2766 | if (!color_transfer_names[i]) | ||
| 2767 | continue; | ||
| 2768 | |||
| 2769 | len = strlen(color_transfer_names[i]); | ||
| 2760 | if (!strncmp(color_transfer_names[i], name, len)) | 2770 | if (!strncmp(color_transfer_names[i], name, len)) |
| 2761 | return i; | 2771 | return i; |
| 2762 | } | 2772 | } |
| @@ -2775,7 +2785,12 @@ int av_color_space_from_name(const char *name) · 12 unmodified lines | |||
| 2775 | int i; | 2785 | int i; |
| 2776 | 2786 | ||
| 2777 | for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) { | 2787 | for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) { |
| 2778 | size_t len = strlen(color_space_names[i]); | 2788 | size_t len; |
| 2789 | |||
| 2790 | if (!color_space_names[i]) | ||
| 2791 | continue; | ||
| 2792 | |||
| 2793 | len = strlen(color_space_names[i]); | ||
| 2779 | if (!strncmp(color_space_names[i], name, len)) | 2794 | if (!strncmp(color_space_names[i], name, len)) |
| 2780 | return i; | 2795 | return i; |
| 2781 | } | 2796 | } |
| @@ -2794,7 +2809,12 @@ int av_chroma_location_from_name(const char *name) · 12 unmodified lines | |||
| 2794 | int i; | 2809 | int i; |
| 2795 | 2810 | ||
| 2796 | for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) { | 2811 | for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) { |
| 2797 | size_t len = strlen(chroma_location_names[i]); | 2812 | size_t len; |
| 2813 | |||
| 2814 | if (!chroma_location_names[i]) | ||
| 2815 | continue; | ||
| 2816 | |||
| 2817 | len = strlen(chroma_location_names[i]); | ||
| 2798 | if (!strncmp(chroma_location_names[i], name, len)) | 2818 | if (!strncmp(chroma_location_names[i], name, len)) |
| 2799 | return i; | 2819 | return i; |
| 2800 | } | 2820 | } |