libavformat/cutils.c:43: error: Null Dereference
  pointer `tab` last assigned on line 40 could be null and is dereferenced at line 43, column 5.

libavformat/cutils.c:27:1: start of procedure ff_dynarray_add()
25. 
26. /* add one element to a dynamic array */
27. void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)
    ^
28. {
29.     /* see similar avconv.c:grow_array() */

libavformat/cutils.c:33:5: 
31.     intptr_t *tab;
32. 
33.     nb = *nb_ptr;
        ^
34.     tab = *tab_ptr;
35.     if ((nb & (nb - 1)) == 0) {

libavformat/cutils.c:34:5: 
32. 
33.     nb = *nb_ptr;
34.     tab = *tab_ptr;
        ^
35.     if ((nb & (nb - 1)) == 0) {
36.         if (nb == 0)

libavformat/cutils.c:35:9: Taking true branch
33.     nb = *nb_ptr;
34.     tab = *tab_ptr;
35.     if ((nb & (nb - 1)) == 0) {
            ^
36.         if (nb == 0)
37.             nb_alloc = 1;

libavformat/cutils.c:36:13: Taking false branch
34.     tab = *tab_ptr;
35.     if ((nb & (nb - 1)) == 0) {
36.         if (nb == 0)
                ^
37.             nb_alloc = 1;
38.         else

libavformat/cutils.c:39:13: 
37.             nb_alloc = 1;
38.         else
39.             nb_alloc = nb * 2;
                ^
40.         tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
41.         *tab_ptr = tab;

libavformat/cutils.c:40:9: 
38.         else
39.             nb_alloc = nb * 2;
40.         tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
            ^
41.         *tab_ptr = tab;
42.     }

libavutil/mem.c:107:1: start of procedure av_realloc()
  105. }
  106. 
  107. void *av_realloc(void *ptr, size_t size)
       ^
  108. {
  109.     /* let's disallow possibly ambiguous cases */

libavutil/mem.c:110:9: Taking false branch
  108. {
  109.     /* let's disallow possibly ambiguous cases */
  110.     if (size > (INT_MAX - 16))
               ^
  111.         return NULL;
  112. 

libavutil/mem.c:116:5: 
  114.     return _aligned_realloc(ptr, size, 32);
  115. #else
  116.     return realloc(ptr, size);
           ^
  117. #endif
  118. }

libavutil/mem.c:118:1: return from a call to av_realloc
  116.     return realloc(ptr, size);
  117. #endif
  118. }
       ^
  119. 
  120. int av_reallocp(void *ptr, size_t size)

libavformat/cutils.c:41:9: 
39.             nb_alloc = nb * 2;
40.         tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
41.         *tab_ptr = tab;
            ^
42.     }
43.     tab[nb++] = elem;

libavformat/cutils.c:43:5: 
41.         *tab_ptr = tab;
42.     }
43.     tab[nb++] = elem;
        ^
44.     *nb_ptr = nb;
45. }

void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)
{
    int nb, nb_alloc;
    intptr_t *tab;
    nb = *nb_ptr;
    tab = *tab_ptr;
    if ((nb & (nb - 1)) == 0) {
        if (nb == 0)
            nb_alloc = 1;
        else
            nb_alloc = nb * 2;
        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
        *tab_ptr = tab;
    }
    tab[nb++] = elem;
    *nb_ptr = nb;
}
['void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)\n{\n    int nb, nb_alloc;\n    intptr_t *tab;\n    nb = *nb_ptr;\n    tab = *tab_ptr;\n    if ((nb & (nb - 1)) == 0) {\n        if (nb == 0)\n            nb_alloc = 1;\n        else\n            nb_alloc = nb * 2;\n        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));\n        *tab_ptr = tab;\n    }\n    tab[nb++] = elem;\n    *nb_ptr = nb;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}']