Fix use of local mem in return value reported by cppcheck

This commit is contained in:
Isaac Connor
2021-02-05 11:04:52 -05:00
parent c28e1b09e5
commit 010674b3dd

View File

@@ -263,22 +263,21 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
void VideoStream::SetParameters( ) {
}
const char *VideoStream::MimeType( ) const {
const char *VideoStream::MimeType() const {
for ( unsigned int i = 0; i < sizeof (mime_data) / sizeof (*mime_data); i++ ) {
if ( strcmp( format, mime_data[i].format ) == 0 ) {
Debug( 1, "MimeType is \"%s\"", mime_data[i].mime_type );
if ( strcmp(format, mime_data[i].format) == 0 ) {
Debug(1, "MimeType is \"%s\"", mime_data[i].mime_type);
return mime_data[i].mime_type;
}
}
const char *mime_type = of->mime_type;
if ( !mime_type ) {
std::string mime = "video/";
mime = mime.append( format );
mime_type = mime.c_str( );
Warning( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type );
std::string mime = std::string("video/") + format;
mime_type = strdup(mime.c_str()); // mem leak
Warning( "Unable to determine mime type for '%s' format, using '%s' as default", format, mime_type);
}
Debug(1, "MimeType is \"%s\"", mime_type );
Debug(1, "MimeType is \"%s\"", mime_type);
return mime_type;
}