avtools/avconv_hw.c:273: error: Null Dereference
  pointer `type_name` last assigned on line 272 could be null and is dereferenced by call to `strlen()` at line 273, column 19.

avtools/avconv_hw.c:253:1: start of procedure hw_device_setup_for_decode()
251. }
252. 
253. int hw_device_setup_for_decode(InputStream *ist)
     ^
254. {
255.     enum AVHWDeviceType type;

avtools/avconv_hw.c:260:9: Taking true branch
258.     int err;
259. 
260.     if (ist->hwaccel_device) {
             ^
261.         dev = hw_device_get_by_name(ist->hwaccel_device);
262.         if (!dev) {

avtools/avconv_hw.c:261:9: 
259. 
260.     if (ist->hwaccel_device) {
261.         dev = hw_device_get_by_name(ist->hwaccel_device);
             ^
262.         if (!dev) {
263.             char *tmp;

avtools/avconv_hw.c:40:1: start of procedure hw_device_get_by_name()
  38. }
  39. 
  40. HWDevice *hw_device_get_by_name(const char *name)
      ^
  41. {
  42.     int i;

avtools/avconv_hw.c:43:10: 
  41. {
  42.     int i;
  43.     for (i = 0; i < nb_hw_devices; i++) {
               ^
  44.         if (!strcmp(hw_devices[i]->name, name))
  45.             return hw_devices[i];

avtools/avconv_hw.c:43:17: Loop condition is true. Entering loop body
  41. {
  42.     int i;
  43.     for (i = 0; i < nb_hw_devices; i++) {
                      ^
  44.         if (!strcmp(hw_devices[i]->name, name))
  45.             return hw_devices[i];

avtools/avconv_hw.c:44:14: Taking false branch
  42.     int i;
  43.     for (i = 0; i < nb_hw_devices; i++) {
  44.         if (!strcmp(hw_devices[i]->name, name))
                   ^
  45.             return hw_devices[i];
  46.     }

avtools/avconv_hw.c:43:36: 
  41. {
  42.     int i;
  43.     for (i = 0; i < nb_hw_devices; i++) {
                                         ^
  44.         if (!strcmp(hw_devices[i]->name, name))
  45.             return hw_devices[i];

avtools/avconv_hw.c:43:17: Loop condition is false. Leaving loop
  41. {
  42.     int i;
  43.     for (i = 0; i < nb_hw_devices; i++) {
                      ^
  44.         if (!strcmp(hw_devices[i]->name, name))
  45.             return hw_devices[i];

avtools/avconv_hw.c:47:5: 
  45.             return hw_devices[i];
  46.     }
  47.     return NULL;
          ^
  48. }
  49. 

avtools/avconv_hw.c:48:1: return from a call to hw_device_get_by_name
  46.     }
  47.     return NULL;
  48. }
      ^
  49. 
  50. static HWDevice *hw_device_add(void)

avtools/avconv_hw.c:262:14: Taking true branch
260.     if (ist->hwaccel_device) {
261.         dev = hw_device_get_by_name(ist->hwaccel_device);
262.         if (!dev) {
                  ^
263.             char *tmp;
264.             size_t len;

avtools/avconv_hw.c:265:13: 
263.             char *tmp;
264.             size_t len;
265.             type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);
                 ^
266.             if (type == AV_HWDEVICE_TYPE_NONE) {
267.                 // No match - this isn't necessarily invalid, though,

avtools/avconv_hw.c:227:1: start of procedure hw_device_match_type_by_hwaccel()
  225. }
  226. 
  227. static enum AVHWDeviceType hw_device_match_type_by_hwaccel(enum HWAccelID hwaccel_id)
       ^
  228. {
  229.     int i;

avtools/avconv_hw.c:230:9: Taking false branch
  228. {
  229.     int i;
  230.     if (hwaccel_id == HWACCEL_NONE)
               ^
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {

avtools/avconv_hw.c:232:10: 
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:232:17: Loop condition is true. Entering loop body
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                       ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:233:13: Taking false branch
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
  233.         if (hwaccels[i].id == hwaccel_id)
                   ^
  234.             return hwaccels[i].device_type;
  235.     }

avtools/avconv_hw.c:232:35: 
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                                         ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:232:17: Loop condition is true. Entering loop body
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                       ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:233:13: Taking false branch
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
  233.         if (hwaccels[i].id == hwaccel_id)
                   ^
  234.             return hwaccels[i].device_type;
  235.     }

avtools/avconv_hw.c:232:35: 
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                                         ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:232:17: Loop condition is true. Entering loop body
  230.     if (hwaccel_id == HWACCEL_NONE)
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
                       ^
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;

avtools/avconv_hw.c:233:13: Taking true branch
  231.         return AV_HWDEVICE_TYPE_NONE;
  232.     for (i = 0; hwaccels[i].name; i++) {
  233.         if (hwaccels[i].id == hwaccel_id)
                   ^
  234.             return hwaccels[i].device_type;
  235.     }

avtools/avconv_hw.c:234:13: 
  232.     for (i = 0; hwaccels[i].name; i++) {
  233.         if (hwaccels[i].id == hwaccel_id)
  234.             return hwaccels[i].device_type;
                   ^
  235.     }
  236.     return AV_HWDEVICE_TYPE_NONE;

avtools/avconv_hw.c:237:1: return from a call to hw_device_match_type_by_hwaccel
  235.     }
  236.     return AV_HWDEVICE_TYPE_NONE;
  237. }
       ^
  238. 
  239. static enum AVHWDeviceType hw_device_match_type_in_name(const char *codec_name)

avtools/avconv_hw.c:266:17: Taking false branch
264.             size_t len;
265.             type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);
266.             if (type == AV_HWDEVICE_TYPE_NONE) {
                     ^
267.                 // No match - this isn't necessarily invalid, though,
268.                 // because an explicit device might not be needed or

avtools/avconv_hw.c:272:13: 
270.                 return 0;
271.             }
272.             type_name = av_hwdevice_get_type_name(type);
                 ^
273.             len = strlen(type_name) + 1 +
274.                   strlen(ist->hwaccel_device) + 1;

libavutil/hwcontext.c:72:1: start of procedure av_hwdevice_get_type_name()
  70. }
  71. 
  72. const char *av_hwdevice_get_type_name(enum AVHWDeviceType type)
      ^
  73. {
  74.     if (type > AV_HWDEVICE_TYPE_NONE &&

libavutil/hwcontext.c:74:9: Taking true branch
  72. const char *av_hwdevice_get_type_name(enum AVHWDeviceType type)
  73. {
  74.     if (type > AV_HWDEVICE_TYPE_NONE &&
              ^
  75.         type < FF_ARRAY_ELEMS(hw_type_names))
  76.         return hw_type_names[type];

libavutil/hwcontext.c:75:9: Taking false branch
  73. {
  74.     if (type > AV_HWDEVICE_TYPE_NONE &&
  75.         type < FF_ARRAY_ELEMS(hw_type_names))
              ^
  76.         return hw_type_names[type];
  77.     else

libavutil/hwcontext.c:78:9: 
  76.         return hw_type_names[type];
  77.     else
  78.         return NULL;
              ^
  79. }
  80. 

libavutil/hwcontext.c:79:1: return from a call to av_hwdevice_get_type_name
  77.     else
  78.         return NULL;
  79. }
      ^
  80. 
  81. enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)

avtools/avconv_hw.c:273:13: 
271.             }
272.             type_name = av_hwdevice_get_type_name(type);
273.             len = strlen(type_name) + 1 +
                 ^
274.                   strlen(ist->hwaccel_device) + 1;
275.             tmp = av_malloc(len);

int hw_device_setup_for_decode(InputStream *ist)
{
    enum AVHWDeviceType type;
    HWDevice *dev;
    const char *type_name;
    int err;
    if (ist->hwaccel_device) {
        dev = hw_device_get_by_name(ist->hwaccel_device);
        if (!dev) {
            char *tmp;
            size_t len;
            type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);
            if (type == AV_HWDEVICE_TYPE_NONE) {
                return 0;
            }
            type_name = av_hwdevice_get_type_name(type);
            len = strlen(type_name) + 1 +
                  strlen(ist->hwaccel_device) + 1;
            tmp = av_malloc(len);
            if (!tmp)
                return AVERROR(ENOMEM);
            snprintf(tmp, len, "%s:%s", type_name, ist->hwaccel_device);
            err = hw_device_init_from_string(tmp, &dev);
            av_free(tmp);
            if (err < 0)
                return err;
        }
    } else {
        if (ist->hwaccel_id != HWACCEL_NONE)
            type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);
        else
            type = hw_device_match_type_in_name(ist->dec->name);
        if (type != AV_HWDEVICE_TYPE_NONE) {
            dev = hw_device_get_by_type(type);
            if (!dev) {
                hw_device_init_from_string(av_hwdevice_get_type_name(type),
                                           &dev);
            }
        } else {
            return 0;
        }
    }
    if (!dev) {
        av_log(ist->dec_ctx, AV_LOG_WARNING, "No device available "
               "for decoder (device type %s for codec %s).\n",
               av_hwdevice_get_type_name(type), ist->dec->name);
        return 0;
    }
    ist->dec_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref);
    if (!ist->dec_ctx->hw_device_ctx)
        return AVERROR(ENOMEM);
    return 0;
}
['int hw_device_setup_for_decode(InputStream *ist)\n{\n    enum AVHWDeviceType type;\n    HWDevice *dev;\n    const char *type_name;\n    int err;\n    if (ist->hwaccel_device) {\n        dev = hw_device_get_by_name(ist->hwaccel_device);\n        if (!dev) {\n            char *tmp;\n            size_t len;\n            type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);\n            if (type == AV_HWDEVICE_TYPE_NONE) {\n                return 0;\n            }\n            type_name = av_hwdevice_get_type_name(type);\n            len = strlen(type_name) + 1 +\n                  strlen(ist->hwaccel_device) + 1;\n            tmp = av_malloc(len);\n            if (!tmp)\n                return AVERROR(ENOMEM);\n            snprintf(tmp, len, "%s:%s", type_name, ist->hwaccel_device);\n            err = hw_device_init_from_string(tmp, &dev);\n            av_free(tmp);\n            if (err < 0)\n                return err;\n        }\n    } else {\n        if (ist->hwaccel_id != HWACCEL_NONE)\n            type = hw_device_match_type_by_hwaccel(ist->hwaccel_id);\n        else\n            type = hw_device_match_type_in_name(ist->dec->name);\n        if (type != AV_HWDEVICE_TYPE_NONE) {\n            dev = hw_device_get_by_type(type);\n            if (!dev) {\n                hw_device_init_from_string(av_hwdevice_get_type_name(type),\n                                           &dev);\n            }\n        } else {\n            return 0;\n        }\n    }\n    if (!dev) {\n        av_log(ist->dec_ctx, AV_LOG_WARNING, "No device available "\n               "for decoder (device type %s for codec %s).\\n",\n               av_hwdevice_get_type_name(type), ist->dec->name);\n        return 0;\n    }\n    ist->dec_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref);\n    if (!ist->dec_ctx->hw_device_ctx)\n        return AVERROR(ENOMEM);\n    return 0;\n}', 'HWDevice *hw_device_get_by_name(const char *name)\n{\n    int i;\n    for (i = 0; i < nb_hw_devices; i++) {\n        if (!strcmp(hw_devices[i]->name, name))\n            return hw_devices[i];\n    }\n    return NULL;\n}', 'static enum AVHWDeviceType hw_device_match_type_by_hwaccel(enum HWAccelID hwaccel_id)\n{\n    int i;\n    if (hwaccel_id == HWACCEL_NONE)\n        return AV_HWDEVICE_TYPE_NONE;\n    for (i = 0; hwaccels[i].name; i++) {\n        if (hwaccels[i].id == hwaccel_id)\n            return hwaccels[i].device_type;\n    }\n    return AV_HWDEVICE_TYPE_NONE;\n}', 'const char *av_hwdevice_get_type_name(enum AVHWDeviceType type)\n{\n    if (type > AV_HWDEVICE_TYPE_NONE &&\n        type < FF_ARRAY_ELEMS(hw_type_names))\n        return hw_type_names[type];\n    else\n        return NULL;\n}']