Assert if we don't have song or song->url set
song objects cannot exist without a path or URL
This commit is contained in:
		 Eric Wong
					Eric Wong
				
			
				
					committed by
					
						 Max Kellermann
						Max Kellermann
					
				
			
			
				
	
			
			
			 Max Kellermann
						Max Kellermann
					
				
			
						parent
						
							016af692d9
						
					
				
				
					commit
					0d34815f6c
				
			| @@ -298,8 +298,8 @@ removeDeletedFromDirectory(char *path_max_tmp, Directory * directory) | |||||||
|  |  | ||||||
| 	for (i = sv->nr; --i >= 0; ) { /* cleaner deletes if we go backwards */ | 	for (i = sv->nr; --i >= 0; ) { /* cleaner deletes if we go backwards */ | ||||||
| 		Song *song = sv->base[i]; | 		Song *song = sv->base[i]; | ||||||
| 		if (!song || !*song->url) | 		assert(song); | ||||||
| 			continue; /* does this happen?, perhaps assert() */ | 		assert(*song->url); | ||||||
|  |  | ||||||
| 		if (dirname) | 		if (dirname) | ||||||
| 			sprintf(path_max_tmp, "%s/%s", dirname, song->url); | 			sprintf(path_max_tmp, "%s/%s", dirname, song->url); | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src/song.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/song.c
									
									
									
									
									
								
							| @@ -31,8 +31,13 @@ | |||||||
| Song * | Song * | ||||||
| song_alloc(const char *url, struct _Directory *parent) | song_alloc(const char *url, struct _Directory *parent) | ||||||
| { | { | ||||||
| 	size_t urllen = strlen(url); | 	size_t urllen; | ||||||
| 	Song *song = xmalloc(sizeof(*song) - sizeof(song->url) + urllen + 1); | 	Song *song; | ||||||
|  |  | ||||||
|  | 	assert(url); | ||||||
|  | 	urllen = strlen(url); | ||||||
|  | 	assert(urllen); | ||||||
|  | 	song = xmalloc(sizeof(*song) - sizeof(song->url) + urllen + 1); | ||||||
|  |  | ||||||
| 	song->tag = NULL; | 	song->tag = NULL; | ||||||
| 	memcpy(song->url, url, urllen + 1); | 	memcpy(song->url, url, urllen + 1); | ||||||
| @@ -44,6 +49,7 @@ song_alloc(const char *url, struct _Directory *parent) | |||||||
| Song *newSong(const char *url, Directory * parentDir) | Song *newSong(const char *url, Directory * parentDir) | ||||||
| { | { | ||||||
| 	Song *song; | 	Song *song; | ||||||
|  | 	assert(*url); | ||||||
|  |  | ||||||
| 	if (strchr(url, '\n')) { | 	if (strchr(url, '\n')) { | ||||||
| 		DEBUG("newSong: '%s' is not a valid uri\n", url); | 		DEBUG("newSong: '%s' is not a valid uri\n", url); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user