libavutil/dict.c:107: error: Null Dereference
  pointer `m->elems` last assigned on line 94 could be null and is dereferenced at line 107, column 13.

libavutil/dict.c:68:1: start of procedure av_dict_set()
66. }
67. 
68. int av_dict_set(AVDictionary **pm, const char *key, const char *value,
    ^
69.                 int flags)
70. {

libavutil/dict.c:71:5: 
69.                 int flags)
70. {
71.     AVDictionary *m = *pm;
        ^
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
73.     char *oldval = NULL;

libavutil/dict.c:72:5: Skipping av_dict_get(): empty list of specs
70. {
71.     AVDictionary *m = *pm;
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
        ^
73.     char *oldval = NULL;
74.     int allocated = !!m;

libavutil/dict.c:73:5: 
71.     AVDictionary *m = *pm;
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
73.     char *oldval = NULL;
        ^
74.     int allocated = !!m;
75. 

libavutil/dict.c:74:23: Condition is false
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
73.     char *oldval = NULL;
74.     int allocated = !!m;
                          ^
75. 
76.     if (!m)

libavutil/dict.c:74:21: 
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
73.     char *oldval = NULL;
74.     int allocated = !!m;
                        ^
75. 
76.     if (!m)

libavutil/dict.c:74:5: 
72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
73.     char *oldval = NULL;
74.     int allocated = !!m;
        ^
75. 
76.     if (!m)

libavutil/dict.c:76:10: Taking false branch
74.     int allocated = !!m;
75. 
76.     if (!m)
             ^
77.         m = *pm = av_mallocz(sizeof(*m));
78.     if (!m)

libavutil/dict.c:78:10: Taking false branch
76.     if (!m)
77.         m = *pm = av_mallocz(sizeof(*m));
78.     if (!m)
             ^
79.         return AVERROR(ENOMEM);
80. 

libavutil/dict.c:81:9: Taking false branch
79.         return AVERROR(ENOMEM);
80. 
81.     if (tag) {
            ^
82.         if (flags & AV_DICT_DONT_OVERWRITE) {
83.             if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);

libavutil/dict.c:94:9: 
92.         *tag = m->elems[--m->count];
93.     } else {
94.         int ret = av_reallocp_array(&m->elems,
            ^
95.                                     m->count + 1, sizeof(*m->elems));
96.         if (ret < 0) {

libavutil/mem.c:167:1: start of procedure av_reallocp_array()
  165. }
  166. 
  167. int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
       ^
  168. {
  169.     void **ptrptr = ptr;

libavutil/mem.c:169:5: 
  167. int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
  168. {
  169.     void **ptrptr = ptr;
           ^
  170.     void *ret;
  171.     if (!size || nmemb >= INT_MAX / size)

libavutil/mem.c:171:10: Taking false branch
  169.     void **ptrptr = ptr;
  170.     void *ret;
  171.     if (!size || nmemb >= INT_MAX / size)
                ^
  172.         return AVERROR(ENOMEM);
  173.     if (!nmemb) {

libavutil/mem.c:171:18: Taking false branch
  169.     void **ptrptr = ptr;
  170.     void *ret;
  171.     if (!size || nmemb >= INT_MAX / size)
                        ^
  172.         return AVERROR(ENOMEM);
  173.     if (!nmemb) {

libavutil/mem.c:173:10: Taking true branch
  171.     if (!size || nmemb >= INT_MAX / size)
  172.         return AVERROR(ENOMEM);
  173.     if (!nmemb) {
                ^
  174.         av_freep(ptr);
  175.         return 0;

libavutil/mem.c:174:9: 
  172.         return AVERROR(ENOMEM);
  173.     if (!nmemb) {
  174.         av_freep(ptr);
               ^
  175.         return 0;
  176.     }

libavutil/mem.c:198:1: start of procedure av_freep()
    196. }
    197. 
    198. void av_freep(void *arg)
         ^
    199. {
    200.     void **ptr = (void **)arg;

libavutil/mem.c:200:5: 
    198. void av_freep(void *arg)
    199. {
    200.     void **ptr = (void **)arg;
             ^
    201.     av_free(*ptr);
    202.     *ptr = NULL;

libavutil/mem.c:201:5: 
    199. {
    200.     void **ptr = (void **)arg;
    201.     av_free(*ptr);
             ^
    202.     *ptr = NULL;
    203. }

libavutil/mem.c:186:1: start of procedure av_free()
      184. }
      185. 
      186. void av_free(void *ptr)
           ^
      187. {
      188. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:194:5: 
      192.     _aligned_free(ptr);
      193. #else
      194.     free(ptr);
               ^
      195. #endif
      196. }

libavutil/mem.c:196:1: return from a call to av_free
      194.     free(ptr);
      195. #endif
      196. }
           ^
      197. 
      198. void av_freep(void *arg)

libavutil/mem.c:202:5: 
    200.     void **ptr = (void **)arg;
    201.     av_free(*ptr);
    202.     *ptr = NULL;
             ^
    203. }
    204. 

libavutil/mem.c:203:1: return from a call to av_freep
    201.     av_free(*ptr);
    202.     *ptr = NULL;
    203. }
         ^
    204. 
    205. void *av_mallocz(size_t size)

libavutil/mem.c:175:9: 
  173.     if (!nmemb) {
  174.         av_freep(ptr);
  175.         return 0;
               ^
  176.     }
  177.     ret = av_realloc(*ptrptr, nmemb * size);

libavutil/mem.c:184:1: return from a call to av_reallocp_array
  182.     *ptrptr = ret;
  183.     return 0;
  184. }
       ^
  185. 
  186. void av_free(void *ptr)

libavutil/dict.c:96:13: Taking false branch
94.         int ret = av_reallocp_array(&m->elems,
95.                                     m->count + 1, sizeof(*m->elems));
96.         if (ret < 0) {
                ^
97.             if (allocated)
98.                 av_freep(pm);

libavutil/dict.c:103:9: Taking true branch
101.         }
102.     }
103.     if (value) {
             ^
104.         if (flags & AV_DICT_DONT_STRDUP_KEY)
105.             m->elems[m->count].key = key;

libavutil/dict.c:104:13: Taking false branch
102.     }
103.     if (value) {
104.         if (flags & AV_DICT_DONT_STRDUP_KEY)
                 ^
105.             m->elems[m->count].key = key;
106.         else

libavutil/dict.c:107:13: 
105.             m->elems[m->count].key = key;
106.         else
107.             m->elems[m->count].key = av_strdup(key);
                 ^
108.         if (flags & AV_DICT_DONT_STRDUP_VAL) {
109.             m->elems[m->count].value = value;

libavutil/mem.c:213:1: start of procedure av_strdup()
  211. }
  212. 
  213. char *av_strdup(const char *s)
       ^
  214. {
  215.     char *ptr = NULL;

libavutil/mem.c:215:5: 
  213. char *av_strdup(const char *s)
  214. {
  215.     char *ptr = NULL;
           ^
  216.     if (s) {
  217.         int len = strlen(s) + 1;

libavutil/mem.c:216:9: Taking false branch
  214. {
  215.     char *ptr = NULL;
  216.     if (s) {
               ^
  217.         int len = strlen(s) + 1;
  218.         ptr = av_realloc(NULL, len);

libavutil/mem.c:222:5: 
  220.             memcpy(ptr, s, len);
  221.     }
  222.     return ptr;
           ^
  223. }
  224. 

libavutil/mem.c:223:1: return from a call to av_strdup
  221.     }
  222.     return ptr;
  223. }
       ^
  224. 
  225. char *av_strndup(const char *s, size_t len)

int av_dict_set(AVDictionary **pm, const char *key, const char *value,
                int flags)
{
    AVDictionary *m = *pm;
    AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
    char *oldval = NULL;
    int allocated = !!m;
    if (!m)
        m = *pm = av_mallocz(sizeof(*m));
    if (!m)
        return AVERROR(ENOMEM);
    if (tag) {
        if (flags & AV_DICT_DONT_OVERWRITE) {
            if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);
            if (flags & AV_DICT_DONT_STRDUP_VAL) av_free(value);
            return 0;
        }
        if (flags & AV_DICT_APPEND)
            oldval = tag->value;
        else
            av_free(tag->value);
        av_free(tag->key);
        *tag = m->elems[--m->count];
    } else {
        int ret = av_reallocp_array(&m->elems,
                                    m->count + 1, sizeof(*m->elems));
        if (ret < 0) {
            if (allocated)
                av_freep(pm);
            return ret;
        }
    }
    if (value) {
        if (flags & AV_DICT_DONT_STRDUP_KEY)
            m->elems[m->count].key = key;
        else
            m->elems[m->count].key = av_strdup(key);
        if (flags & AV_DICT_DONT_STRDUP_VAL) {
            m->elems[m->count].value = value;
        } else if (oldval && flags & AV_DICT_APPEND) {
            int len = strlen(oldval) + strlen(value) + 1;
            if (!(oldval = av_realloc(oldval, len)))
                return AVERROR(ENOMEM);
            av_strlcat(oldval, value, len);
            m->elems[m->count].value = oldval;
        } else
            m->elems[m->count].value = av_strdup(value);
        m->count++;
    }
    if (!m->count) {
        av_free(m->elems);
        av_freep(pm);
    }
    return 0;
}
['int av_dict_set(AVDictionary **pm, const char *key, const char *value,\n                int flags)\n{\n    AVDictionary *m = *pm;\n    AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);\n    char *oldval = NULL;\n    int allocated = !!m;\n    if (!m)\n        m = *pm = av_mallocz(sizeof(*m));\n    if (!m)\n        return AVERROR(ENOMEM);\n    if (tag) {\n        if (flags & AV_DICT_DONT_OVERWRITE) {\n            if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);\n            if (flags & AV_DICT_DONT_STRDUP_VAL) av_free(value);\n            return 0;\n        }\n        if (flags & AV_DICT_APPEND)\n            oldval = tag->value;\n        else\n            av_free(tag->value);\n        av_free(tag->key);\n        *tag = m->elems[--m->count];\n    } else {\n        int ret = av_reallocp_array(&m->elems,\n                                    m->count + 1, sizeof(*m->elems));\n        if (ret < 0) {\n            if (allocated)\n                av_freep(pm);\n            return ret;\n        }\n    }\n    if (value) {\n        if (flags & AV_DICT_DONT_STRDUP_KEY)\n            m->elems[m->count].key = key;\n        else\n            m->elems[m->count].key = av_strdup(key);\n        if (flags & AV_DICT_DONT_STRDUP_VAL) {\n            m->elems[m->count].value = value;\n        } else if (oldval && flags & AV_DICT_APPEND) {\n            int len = strlen(oldval) + strlen(value) + 1;\n            if (!(oldval = av_realloc(oldval, len)))\n                return AVERROR(ENOMEM);\n            av_strlcat(oldval, value, len);\n            m->elems[m->count].value = oldval;\n        } else\n            m->elems[m->count].value = av_strdup(value);\n        m->count++;\n    }\n    if (!m->count) {\n        av_free(m->elems);\n        av_freep(pm);\n    }\n    return 0;\n}', 'int av_reallocp_array(void *ptr, size_t nmemb, size_t size)\n{\n    void **ptrptr = ptr;\n    void *ret;\n    if (!size || nmemb >= INT_MAX / size)\n        return AVERROR(ENOMEM);\n    if (!nmemb) {\n        av_freep(ptr);\n        return 0;\n    }\n    ret = av_realloc(*ptrptr, nmemb * size);\n    if (!ret) {\n        av_freep(ptr);\n        return AVERROR(ENOMEM);\n    }\n    *ptrptr = ret;\n    return 0;\n}', 'void av_freep(void *arg)\n{\n    void **ptr = (void **)arg;\n    av_free(*ptr);\n    *ptr = NULL;\n}', 'void av_free(void *ptr)\n{\n#if CONFIG_MEMALIGN_HACK\n    if (ptr)\n        free((char *)ptr - ((char *)ptr)[-1]);\n#elif HAVE_ALIGNED_MALLOC\n    _aligned_free(ptr);\n#else\n    free(ptr);\n#endif\n}', 'char *av_strdup(const char *s)\n{\n    char *ptr = NULL;\n    if (s) {\n        int len = strlen(s) + 1;\n        ptr = av_realloc(NULL, len);\n        if (ptr)\n            memcpy(ptr, s, len);\n    }\n    return ptr;\n}']