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

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

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

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

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

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

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

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

libavutil/mem.c:116:1: start of procedure av_realloc()
  114. }
  115. 
  116. void *av_realloc(void *ptr, size_t size)
       ^
  117. {
  118. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:123:9: Taking false branch
  121. 
  122.     /* let's disallow possibly ambiguous cases */
  123.     if (size > (INT_MAX - 16))
               ^
  124.         return NULL;
  125. 

libavutil/mem.c:135:5: 
  133.     return _aligned_realloc(ptr, size, 32);
  134. #else
  135.     return realloc(ptr, size);
           ^
  136. #endif
  137. }

libavutil/mem.c:137:1: return from a call to av_realloc
  135.     return realloc(ptr, size);
  136. #endif
  137. }
       ^
  138. 
  139. int av_reallocp(void *ptr, size_t size)

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

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

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 CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    if (!ptr)\n        return av_malloc(size);\n    diff = ((char *)ptr)[-1];\n    return (char *)realloc((char *)ptr - diff, size + diff) + diff;\n#elif HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}']