tracker r2487 - trunk/src/tracker-extract



Author: mottela
Date: Tue Nov 11 20:27:31 2008
New Revision: 2487
URL: http://svn.gnome.org/viewvc/tracker?rev=2487&view=rev

Log:
Minor leak and bug fixes to the mp3 extractor

Modified:
   trunk/src/tracker-extract/tracker-extract-mp3.c

Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c	Tue Nov 11 20:27:31 2008
@@ -617,21 +617,21 @@
 				switch (data[pos + 10]) {
 				case 0x00:
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "ISO-8859-1",
 							 NULL, NULL, NULL);
 					break;
 				case 0x01 :
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "UTF-16",
 							 NULL, NULL, NULL);
 					break;
 				case 0x02 :
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "UTF-16BE",
 							 NULL, NULL, NULL);
@@ -646,7 +646,7 @@
 					 * iso-8859-1
 					 */
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "ISO-8859-1",
 							 NULL, NULL, NULL);
@@ -657,24 +657,10 @@
 				csize--;
 
 				if (word != NULL && strlen (word) > 0) {       
-					/* Genre to text */
-					if ((strcmp (tmap[i].text, "TCON") == 0) ||
-					    (strcmp (tmap[i].text, "TIT1") == 0)) {
-						guint genre;
-
-						genre = strtoul (word, NULL, 10);
-						if ((guint) genre < G_N_ELEMENTS (genre_names)) {
-							gchar *s;
-						
-							s = g_strdup (genre_names[genre]);
-							g_free (word);
-							word = s;
-						}
-					}
 
 					g_hash_table_insert (metadata,
 							     g_strdup (tmap[i].type),
-							     g_strdup (word));
+							     word);
 				} else {
 					g_free (word);
 				}
@@ -704,27 +690,27 @@
 			switch (text_encode) {
 			case 0x00:
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "ISO-8859-1",
 						 NULL, NULL, NULL);
 				break;
 			case 0x01 :
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "UTF-16",
 						 NULL, NULL, NULL);
 				break;
 			case 0x02 :
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "UTF-16BE",
 						 NULL, NULL, NULL);
 				break;
 			case 0x03 :
-				word = strndup (text, csize-offset);
+				word = strndup (text, csize-offset-1);
 				break;
 				
 			default:
@@ -743,7 +729,7 @@
 			if (word != NULL && strlen (word) > 0) {
 				g_hash_table_insert (metadata,
 						     g_strdup ("Audio:Comment"),
-						     g_strdup (word));	
+						     word);	
 			} else {
 				g_free (word);
 			}
@@ -894,8 +880,6 @@
 					csize--;
 				}
 
-				csize--;
-
 				/* This byte describes the encoding
 				 * try to convert strings to UTF-8 if
 				 * it fails, then forget it./
@@ -904,14 +888,14 @@
 				switch (data[pos + 10]) {
 				case 0x00:
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "ISO-8859-1",
 							 NULL, NULL, NULL);
 					break;
 				case 0x01 :
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "UCS-2",
 							 NULL, NULL, NULL);
@@ -922,7 +906,7 @@
 					 * iso-8859-1
 					 */
 					word = g_convert(&data[pos+11],
-							 csize,
+							 csize-1,
 							 "UTF-8",
 							 "ISO-8859-1",
 							 NULL, NULL, NULL);
@@ -930,6 +914,7 @@
 				}
 
 				pos++;
+				csize--;
 
 				if (word != NULL && strlen(word) > 0) {
 					if (strcmp (tmap[i].text, "COMM") == 0) {
@@ -940,24 +925,9 @@
 						word = s;
 					}
 
-					/* Genre to text */
-					if ((strcmp (tmap[i].text, "TCON") == 0) ||
-					    (strcmp (tmap[i].text, "TIT1") == 0)) {
-						guint genre;
-
-						genre = strtoul (word, NULL, 10);
-						if ((guint) genre < G_N_ELEMENTS (genre_names)) {
-							gchar *s;
-						
-							s = g_strdup (genre_names[genre]);
-							g_free (word);
-							word = s;
-						}
-					}
-
 					g_hash_table_insert (metadata,
 							     g_strdup (tmap[i].type),
-							     g_strdup (word));
+							     word);
 				} else {
 					g_free (word);
 				}
@@ -987,14 +957,14 @@
 			switch (text_encode) {
 			case 0x00:
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "ISO-8859-1",
 						 NULL, NULL, NULL);
 				break;
 			case 0x01 :
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "UCS-2",
 						 NULL, NULL, NULL);
@@ -1005,7 +975,7 @@
 				 * iso-8859-1
 				 */
 				word = g_convert(text,
-						 csize-offset,
+						 csize-offset-1,
 						 "UTF-8",
 						 "ISO-8859-1",
 						 NULL, NULL, NULL);
@@ -1015,7 +985,7 @@
 			if (word != NULL && strlen (word) > 0) {
 				g_hash_table_insert (metadata,
 						     g_strdup ("Audio:Comment"),
-						     g_strdup (word));	
+						     word);	
 			} else {
 				g_free (word);
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]