libavcodec/mp3_header_compress_bsf.c:53: error: Null Dereference
  pointer `avctx->extradata` last assigned on line 52 could be null and is dereferenced by call to `strcpy()` at line 53, column 9.

libavcodec/mp3_header_compress_bsf.c:27:1: start of procedure mp3_header_compress()
25. 
26. 
27. static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
    ^
28.                      uint8_t **poutbuf, int *poutbuf_size,
29.                      const uint8_t *buf, int buf_size, int keyframe){

libavcodec/mp3_header_compress_bsf.c:33:8: Taking false branch
31.     int mode_extension, header_size;
32. 
33.     if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
           ^
34.         av_log(avctx, AV_LOG_ERROR, "not standards compliant\n");
35.         return -1;

libavcodec/mp3_header_compress_bsf.c:38:5: 
36.     }
37. 
38.     header = AV_RB32(buf);
        ^
39.     mode_extension= (header>>4)&3;
40. 

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavutil/bswap.h:66:1: start of procedure av_bswap32()
  64. 
  65. #ifndef av_bswap32
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      ^
  67. {
  68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
  66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
  67. {
  68.     return AV_BSWAP32C(x);
          ^
  69. }
  70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
  67. {
  68.     return AV_BSWAP32C(x);
  69. }
      ^
  70. #endif
  71. 

libavcodec/mp3_header_compress_bsf.c:39:5: 
37. 
38.     header = AV_RB32(buf);
39.     mode_extension= (header>>4)&3;
        ^
40. 
41.     if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){

libavcodec/mp3_header_compress_bsf.c:41:8: 
39.     mode_extension= (header>>4)&3;
40. 
41.     if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){
           ^
42. output_unchanged:
43.         *poutbuf= (uint8_t *) buf;

libavcodec/mpegaudiodecheader.h:60:1: start of procedure ff_mpa_check_header()
  58. 
  59. /* fast header check for resync */
  60. static inline int ff_mpa_check_header(uint32_t header){
      ^
  61.     /* header */
  62.     if ((header & 0xffe00000) != 0xffe00000)

libavcodec/mpegaudiodecheader.h:62:9: Taking false branch
  60. static inline int ff_mpa_check_header(uint32_t header){
  61.     /* header */
  62.     if ((header & 0xffe00000) != 0xffe00000)
              ^
  63.         return -1;
  64.     /* layer check */

libavcodec/mpegaudiodecheader.h:65:9: Taking false branch
  63.         return -1;
  64.     /* layer check */
  65.     if ((header & (3<<17)) == 0)
              ^
  66.         return -1;
  67.     /* bit rate */

libavcodec/mpegaudiodecheader.h:68:9: Taking false branch
  66.         return -1;
  67.     /* bit rate */
  68.     if ((header & (0xf<<12)) == 0xf<<12)
              ^
  69.         return -1;
  70.     /* frequency */

libavcodec/mpegaudiodecheader.h:71:9: Taking false branch
  69.         return -1;
  70.     /* frequency */
  71.     if ((header & (3<<10)) == 3<<10)
              ^
  72.         return -1;
  73.     return 0;

libavcodec/mpegaudiodecheader.h:73:5: 
  71.     if ((header & (3<<10)) == 3<<10)
  72.         return -1;
  73.     return 0;
          ^
  74. }
  75. 

libavcodec/mpegaudiodecheader.h:74:1: return from a call to ff_mpa_check_header
  72.         return -1;
  73.     return 0;
  74. }
      ^
  75. 
  76. #endif /* AVCODEC_MPEGAUDIODECHEADER_H */

libavcodec/mp3_header_compress_bsf.c:41:8: Taking false branch
39.     mode_extension= (header>>4)&3;
40. 
41.     if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){
           ^
42. output_unchanged:
43.         *poutbuf= (uint8_t *) buf;

libavcodec/mp3_header_compress_bsf.c:41:43: Taking false branch
39.     mode_extension= (header>>4)&3;
40. 
41.     if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){
                                              ^
42. output_unchanged:
43.         *poutbuf= (uint8_t *) buf;

libavcodec/mp3_header_compress_bsf.c:50:8: Taking true branch
48.     }
49. 
50.     if(avctx->extradata_size == 0){
           ^
51.         avctx->extradata_size=15;
52.         avctx->extradata= av_malloc(avctx->extradata_size);

libavcodec/mp3_header_compress_bsf.c:51:9: 
49. 
50.     if(avctx->extradata_size == 0){
51.         avctx->extradata_size=15;
            ^
52.         avctx->extradata= av_malloc(avctx->extradata_size);
53.         strcpy(avctx->extradata, "FFCMP3 0.0");

libavcodec/mp3_header_compress_bsf.c:52:9: 
50.     if(avctx->extradata_size == 0){
51.         avctx->extradata_size=15;
52.         avctx->extradata= av_malloc(avctx->extradata_size);
            ^
53.         strcpy(avctx->extradata, "FFCMP3 0.0");
54.         memcpy(avctx->extradata+11, buf, 4);

libavutil/mem.c:61:1: start of procedure av_malloc()
  59.  * linker will do it automatically. */
  60. 
  61. void *av_malloc(size_t size)
      ^
  62. {
  63.     void *ptr = NULL;

libavutil/mem.c:63:5: 
  61. void *av_malloc(size_t size)
  62. {
  63.     void *ptr = NULL;
          ^
  64. #if CONFIG_MEMALIGN_HACK
  65.     long diff;

libavutil/mem.c:69:9: Taking false branch
  67. 
  68.     /* let's disallow possibly ambiguous cases */
  69.     if (size > (INT_MAX - 32) || !size)
              ^
  70.         return NULL;
  71. 

libavutil/mem.c:69:35: Taking false branch
  67. 
  68.     /* let's disallow possibly ambiguous cases */
  69.     if (size > (INT_MAX - 32) || !size)
                                        ^
  70.         return NULL;
  71. 

libavutil/mem.c:80:9: Taking true branch
  78.     ((char *)ptr)[-1] = diff;
  79. #elif HAVE_POSIX_MEMALIGN
  80.     if (posix_memalign(&ptr, 32, size))
              ^
  81.         ptr = NULL;
  82. #elif HAVE_ALIGNED_MALLOC

libavutil/mem.c:81:9: 
  79. #elif HAVE_POSIX_MEMALIGN
  80.     if (posix_memalign(&ptr, 32, size))
  81.         ptr = NULL;
              ^
  82. #elif HAVE_ALIGNED_MALLOC
  83.     ptr = _aligned_malloc(size, 32);

libavutil/mem.c:113:5: 
  111.     ptr = malloc(size);
  112. #endif
  113.     return ptr;
           ^
  114. }
  115. 

libavutil/mem.c:114:1: return from a call to av_malloc
  112. #endif
  113.     return ptr;
  114. }
       ^
  115. 
  116. void *av_realloc(void *ptr, size_t size)

libavcodec/mp3_header_compress_bsf.c:53:9: 
51.         avctx->extradata_size=15;
52.         avctx->extradata= av_malloc(avctx->extradata_size);
53.         strcpy(avctx->extradata, "FFCMP3 0.0");
            ^
54.         memcpy(avctx->extradata+11, buf, 4);
55.     }

static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
                     uint8_t **poutbuf, int *poutbuf_size,
                     const uint8_t *buf, int buf_size, int keyframe){
    uint32_t header, extraheader;
    int mode_extension, header_size;
    if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
        av_log(avctx, AV_LOG_ERROR, "not standards compliant\n");
        return -1;
    }
    header = AV_RB32(buf);
    mode_extension= (header>>4)&3;
    if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){
output_unchanged:
        *poutbuf= (uint8_t *) buf;
        *poutbuf_size= buf_size;
        av_log(avctx, AV_LOG_INFO, "cannot compress %08X\n", header);
        return 0;
    }
    if(avctx->extradata_size == 0){
        avctx->extradata_size=15;
        avctx->extradata= av_malloc(avctx->extradata_size);
        strcpy(avctx->extradata, "FFCMP3 0.0");
        memcpy(avctx->extradata+11, buf, 4);
    }
    if(avctx->extradata_size != 15){
        av_log(avctx, AV_LOG_ERROR, "Extradata invalid\n");
        return -1;
    }
    extraheader = AV_RB32(avctx->extradata+11);
    if((extraheader&MP3_MASK) != (header&MP3_MASK))
        goto output_unchanged;
    header_size= (header&0x10000) ? 4 : 6;
    *poutbuf_size= buf_size - header_size;
    *poutbuf= av_malloc(buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE);
    memcpy(*poutbuf, buf + header_size, buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE);
    if(avctx->channels==2){
        if((header & (3<<19)) != 3<<19){
            (*poutbuf)[1] &= 0x3F;
            (*poutbuf)[1] |= mode_extension<<6;
            FFSWAP(int, (*poutbuf)[1], (*poutbuf)[2]);
        }else{
            (*poutbuf)[1] &= 0x8F;
            (*poutbuf)[1] |= mode_extension<<4;
        }
    }
    return 1;
}
['static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,\n                     uint8_t **poutbuf, int *poutbuf_size,\n                     const uint8_t *buf, int buf_size, int keyframe){\n    uint32_t header, extraheader;\n    int mode_extension, header_size;\n    if(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){\n        av_log(avctx, AV_LOG_ERROR, "not standards compliant\\n");\n        return -1;\n    }\n    header = AV_RB32(buf);\n    mode_extension= (header>>4)&3;\n    if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){\noutput_unchanged:\n        *poutbuf= (uint8_t *) buf;\n        *poutbuf_size= buf_size;\n        av_log(avctx, AV_LOG_INFO, "cannot compress %08X\\n", header);\n        return 0;\n    }\n    if(avctx->extradata_size == 0){\n        avctx->extradata_size=15;\n        avctx->extradata= av_malloc(avctx->extradata_size);\n        strcpy(avctx->extradata, "FFCMP3 0.0");\n        memcpy(avctx->extradata+11, buf, 4);\n    }\n    if(avctx->extradata_size != 15){\n        av_log(avctx, AV_LOG_ERROR, "Extradata invalid\\n");\n        return -1;\n    }\n    extraheader = AV_RB32(avctx->extradata+11);\n    if((extraheader&MP3_MASK) != (header&MP3_MASK))\n        goto output_unchanged;\n    header_size= (header&0x10000) ? 4 : 6;\n    *poutbuf_size= buf_size - header_size;\n    *poutbuf= av_malloc(buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE);\n    memcpy(*poutbuf, buf + header_size, buf_size - header_size + FF_INPUT_BUFFER_PADDING_SIZE);\n    if(avctx->channels==2){\n        if((header & (3<<19)) != 3<<19){\n            (*poutbuf)[1] &= 0x3F;\n            (*poutbuf)[1] |= mode_extension<<6;\n            FFSWAP(int, (*poutbuf)[1], (*poutbuf)[2]);\n        }else{\n            (*poutbuf)[1] &= 0x8F;\n            (*poutbuf)[1] |= mode_extension<<4;\n        }\n    }\n    return 1;\n}', 'static av_always_inline av_const uint32_t av_bswap32(uint32_t x)\n{\n    return AV_BSWAP32C(x);\n}', 'static inline int ff_mpa_check_header(uint32_t header){\n    if ((header & 0xffe00000) != 0xffe00000)\n        return -1;\n    if ((header & (3<<17)) == 0)\n        return -1;\n    if ((header & (0xf<<12)) == 0xf<<12)\n        return -1;\n    if ((header & (3<<10)) == 3<<10)\n        return -1;\n    return 0;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if (size > (INT_MAX - 32) || !size)\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size + 32);\n    if (!ptr)\n        return ptr;\n    diff              = ((-(long)ptr - 1) & 31) + 1;\n    ptr               = (char *)ptr + diff;\n    ((char *)ptr)[-1] = diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr, 32, size))\n        ptr = NULL;\n#elif HAVE_ALIGNED_MALLOC\n    ptr = _aligned_malloc(size, 32);\n#elif HAVE_MEMALIGN\n    ptr = memalign(32, size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']