id3v2: strdup the genre name explicitly.
It would have been done anyway in the av_dict_set() call. This simplifies the code and avoid a warning because of assigning a const string from ff_id3v1_genre_str to a non-const variable. Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
		
							parent
							
								
									ffdd2e9144
								
							
						
					
					
						commit
						049ce4facb
					
				@ -262,7 +262,7 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding,
 | 
				
			|||||||
static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key)
 | 
					static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const char *key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    uint8_t *dst;
 | 
					    uint8_t *dst;
 | 
				
			||||||
    int encoding, dict_flags = AV_DICT_DONT_OVERWRITE;
 | 
					    int encoding, dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
 | 
				
			||||||
    unsigned genre;
 | 
					    unsigned genre;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (taglen < 1)
 | 
					    if (taglen < 1)
 | 
				
			||||||
@ -280,7 +280,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
 | 
				
			|||||||
        && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
 | 
					        && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
 | 
				
			||||||
        && genre <= ID3v1_GENRE_MAX) {
 | 
					        && genre <= ID3v1_GENRE_MAX) {
 | 
				
			||||||
        av_freep(&dst);
 | 
					        av_freep(&dst);
 | 
				
			||||||
        dst = ff_id3v1_genre_str[genre];
 | 
					        dst = av_strdup(ff_id3v1_genre_str[genre]);
 | 
				
			||||||
    } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) {
 | 
					    } else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) {
 | 
				
			||||||
        /* dst now contains the key, need to get value */
 | 
					        /* dst now contains the key, need to get value */
 | 
				
			||||||
        key = dst;
 | 
					        key = dst;
 | 
				
			||||||
@ -289,11 +289,8 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
 | 
				
			|||||||
            av_freep(&key);
 | 
					            av_freep(&key);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        dict_flags |= AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_STRDUP_KEY;
 | 
					        dict_flags |= AV_DICT_DONT_STRDUP_KEY;
 | 
				
			||||||
    }
 | 
					    } else if (!*dst)
 | 
				
			||||||
    else if (*dst)
 | 
					 | 
				
			||||||
        dict_flags |= AV_DICT_DONT_STRDUP_VAL;
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        av_freep(&dst);
 | 
					        av_freep(&dst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (dst)
 | 
					    if (dst)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user