aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-15 20:12:53 +0200
committerChristian Grothoff <christian@grothoff.org>2017-10-15 20:12:53 +0200
commite0fba0ff1664c1762bd3367f1136ca3f9c9052f2 (patch)
tree9886302e8f6f69ba7a731a8969fff7622a313a9c
parenta0268aec1e494ac26b986454803f1c869e0fe58b (diff)
downloadlibextractor-e0fba0ff1664c1762bd3367f1136ca3f9c9052f2.tar.gz
libextractor-e0fba0ff1664c1762bd3367f1136ca3f9c9052f2.zip
be more careful with memory allocation failures in gsf extractor, avoid calling g_free(NULL)
-rw-r--r--src/plugins/gstreamer_extractor.c357
-rw-r--r--src/plugins/ole2_extractor.c4
2 files changed, 249 insertions, 112 deletions
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c
index 8bffd97..2f47adf 100644
--- a/src/plugins/gstreamer_extractor.c
+++ b/src/plugins/gstreamer_extractor.c
@@ -1078,8 +1078,11 @@ send_structure_foreach (GQuark field_id,
1078 /* This is a potential source of invalid characters */ 1078 /* This is a potential source of invalid characters */
1079 /* And it also might attempt to serialize binary data - such as images. */ 1079 /* And it also might attempt to serialize binary data - such as images. */
1080 str = gst_value_serialize (value); 1080 str = gst_value_serialize (value);
1081 g_free (str); 1081 if (NULL != str)
1082 str = NULL; 1082 {
1083 g_free (str);
1084 str = NULL;
1085 }
1083 break; 1086 break;
1084 } 1087 }
1085 if (NULL != str) 1088 if (NULL != str)
@@ -1093,21 +1096,33 @@ send_structure_foreach (GQuark field_id,
1093 named_tags[i].le_type, 1096 named_tags[i].le_type,
1094 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1097 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
1095 (const char *) str, strlen (str) + 1); 1098 (const char *) str, strlen (str) + 1);
1096 g_free (str); 1099 if (NULL != str)
1097 str = NULL; 1100 {
1101 g_free (str);
1102 str = NULL;
1103 }
1098 break; 1104 break;
1099 } 1105 }
1100 } 1106 }
1101 if (NULL != str) 1107 if (NULL != str)
1102 { 1108 {
1103 gchar *senddata = g_strdup_printf ("%s=%s", field_name, str); 1109 gchar *senddata = g_strdup_printf ("%s=%s",
1104 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1110 field_name,
1105 EXTRACTOR_METATYPE_UNKNOWN, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1111 str);
1106 (const char *) senddata, 1112 if (NULL != senddata)
1107 strlen (senddata) + 1); 1113 {
1108 g_free (senddata); 1114 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1115 "gstreamer",
1116 EXTRACTOR_METATYPE_UNKNOWN,
1117 EXTRACTOR_METAFORMAT_UTF8,
1118 "text/plain",
1119 (const char *) senddata,
1120 strlen (senddata) + 1);
1121 g_free (senddata);
1122 }
1109 } 1123 }
1110 g_free (str); 1124 if (NULL != str)
1125 g_free (str);
1111 1126
1112 return ! ps->time_to_leave; 1127 return ! ps->time_to_leave;
1113} 1128}
@@ -1141,10 +1156,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
1141 if (u > 0) 1156 if (u > 0)
1142 { 1157 {
1143 tmp = g_strdup_printf ("%u", u); 1158 tmp = g_strdup_printf ("%u", u);
1144 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1159 if (NULL != tmp)
1145 EXTRACTOR_METATYPE_CHANNELS, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1160 {
1146 (const char *) tmp, strlen (tmp) + 1); 1161 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1147 g_free (tmp); 1162 "gstreamer",
1163 EXTRACTOR_METATYPE_CHANNELS,
1164 EXTRACTOR_METAFORMAT_UTF8,
1165 "text/plain",
1166 (const char *) tmp,
1167 strlen (tmp) + 1);
1168 g_free (tmp);
1169 }
1148 if (ps->time_to_leave) 1170 if (ps->time_to_leave)
1149 return TRUE; 1171 return TRUE;
1150 } 1172 }
@@ -1153,10 +1175,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
1153 if (u > 0) 1175 if (u > 0)
1154 { 1176 {
1155 tmp = g_strdup_printf ("%u", u); 1177 tmp = g_strdup_printf ("%u", u);
1156 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1178 if (NULL != tmp)
1157 EXTRACTOR_METATYPE_SAMPLE_RATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1179 {
1158 (const char *) tmp, strlen (tmp) + 1); 1180 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1159 g_free (tmp); 1181 "gstreamer",
1182 EXTRACTOR_METATYPE_SAMPLE_RATE,
1183 EXTRACTOR_METAFORMAT_UTF8,
1184 "text/plain",
1185 (const char *) tmp,
1186 strlen (tmp) + 1);
1187 g_free (tmp);
1188 }
1160 if (ps->time_to_leave) 1189 if (ps->time_to_leave)
1161 return TRUE; 1190 return TRUE;
1162 } 1191 }
@@ -1165,10 +1194,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
1165 if (u > 0) 1194 if (u > 0)
1166 { 1195 {
1167 tmp = g_strdup_printf ("%u", u); 1196 tmp = g_strdup_printf ("%u", u);
1168 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1197 if (NULL != tmp)
1169 EXTRACTOR_METATYPE_AUDIO_DEPTH, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1198 {
1170 (const char *) tmp, strlen (tmp) + 1); 1199 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1171 g_free (tmp); 1200 "gstreamer",
1201 EXTRACTOR_METATYPE_AUDIO_DEPTH,
1202 EXTRACTOR_METAFORMAT_UTF8,
1203 "text/plain",
1204 (const char *) tmp,
1205 strlen (tmp) + 1);
1206 g_free (tmp);
1207 }
1172 if (ps->time_to_leave) 1208 if (ps->time_to_leave)
1173 return TRUE; 1209 return TRUE;
1174 } 1210 }
@@ -1177,10 +1213,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
1177 if (u > 0) 1213 if (u > 0)
1178 { 1214 {
1179 tmp = g_strdup_printf ("%u", u); 1215 tmp = g_strdup_printf ("%u", u);
1180 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1216 if (NULL != tmp)
1181 EXTRACTOR_METATYPE_AUDIO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1217 {
1182 (const char *) tmp, strlen (tmp) + 1); 1218 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1183 g_free (tmp); 1219 "gstreamer",
1220 EXTRACTOR_METATYPE_AUDIO_BITRATE,
1221 EXTRACTOR_METAFORMAT_UTF8,
1222 "text/plain",
1223 (const char *) tmp,
1224 strlen (tmp) + 1);
1225 g_free (tmp);
1226 }
1184 if (ps->time_to_leave) 1227 if (ps->time_to_leave)
1185 return TRUE; 1228 return TRUE;
1186 } 1229 }
@@ -1189,10 +1232,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
1189 if (u > 0) 1232 if (u > 0)
1190 { 1233 {
1191 tmp = g_strdup_printf ("%u", u); 1234 tmp = g_strdup_printf ("%u", u);
1192 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1235 if (NULL != tmp)
1193 EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1236 {
1194 (const char *) tmp, strlen (tmp) + 1); 1237 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1195 g_free (tmp); 1238 "gstreamer",
1239 EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE,
1240 EXTRACTOR_METAFORMAT_UTF8,
1241 "text/plain",
1242 (const char *) tmp,
1243 strlen (tmp) + 1);
1244 g_free (tmp);
1245 }
1196 if (ps->time_to_leave) 1246 if (ps->time_to_leave)
1197 return TRUE; 1247 return TRUE;
1198 } 1248 }
@@ -1221,10 +1271,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1221 if ( (u > 0) && (u2 > 0) ) 1271 if ( (u > 0) && (u2 > 0) )
1222 { 1272 {
1223 tmp = g_strdup_printf ("%ux%u", u, u2); 1273 tmp = g_strdup_printf ("%ux%u", u, u2);
1224 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1274 if (NULL != tmp)
1225 EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1275 {
1226 (const char *) tmp, strlen (tmp) + 1); 1276 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1227 g_free (tmp); 1277 "gstreamer",
1278 EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
1279 EXTRACTOR_METAFORMAT_UTF8,
1280 "text/plain",
1281 (const char *) tmp,
1282 strlen (tmp) + 1);
1283 g_free (tmp);
1284 }
1228 if (ps->time_to_leave) 1285 if (ps->time_to_leave)
1229 return TRUE; 1286 return TRUE;
1230 } 1287 }
@@ -1233,10 +1290,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1233 if (u > 0) 1290 if (u > 0)
1234 { 1291 {
1235 tmp = g_strdup_printf ("%u", u); 1292 tmp = g_strdup_printf ("%u", u);
1236 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1293 if (NULL != tmp)
1237 EXTRACTOR_METATYPE_VIDEO_DEPTH, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1294 {
1238 (const char *) tmp, strlen (tmp) + 1); 1295 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1239 g_free (tmp); 1296 "gstreamer",
1297 EXTRACTOR_METATYPE_VIDEO_DEPTH,
1298 EXTRACTOR_METAFORMAT_UTF8,
1299 "text/plain",
1300 (const char *) tmp,
1301 strlen (tmp) + 1);
1302 g_free (tmp);
1303 }
1240 if (ps->time_to_leave) 1304 if (ps->time_to_leave)
1241 return TRUE; 1305 return TRUE;
1242 } 1306 }
@@ -1246,10 +1310,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1246 if ( (u > 0) && (u2 > 0) ) 1310 if ( (u > 0) && (u2 > 0) )
1247 { 1311 {
1248 tmp = g_strdup_printf ("%u/%u", u, u2); 1312 tmp = g_strdup_printf ("%u/%u", u, u2);
1249 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1313 if (NULL != tmp)
1250 EXTRACTOR_METATYPE_FRAME_RATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1314 {
1251 (const char *) tmp, strlen (tmp) + 1); 1315 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1252 g_free (tmp); 1316 "gstreamer",
1317 EXTRACTOR_METATYPE_FRAME_RATE,
1318 EXTRACTOR_METAFORMAT_UTF8,
1319 "text/plain",
1320 (const char *) tmp,
1321 strlen (tmp) + 1);
1322 g_free (tmp);
1323 }
1253 if (ps->time_to_leave) 1324 if (ps->time_to_leave)
1254 return TRUE; 1325 return TRUE;
1255 } 1326 }
@@ -1259,10 +1330,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1259 if ( (u > 0) && (u2 > 0) ) 1330 if ( (u > 0) && (u2 > 0) )
1260 { 1331 {
1261 tmp = g_strdup_printf ("%u/%u", u, u2); 1332 tmp = g_strdup_printf ("%u/%u", u, u2);
1262 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1333 if (NULL != tmp)
1263 EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1334 {
1264 (const char *) tmp, strlen (tmp) + 1); 1335 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1265 g_free (tmp); 1336 "gstreamer",
1337 EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
1338 EXTRACTOR_METAFORMAT_UTF8,
1339 "text/plain",
1340 (const char *) tmp,
1341 strlen (tmp) + 1);
1342 g_free (tmp);
1343 }
1266 if (ps->time_to_leave) 1344 if (ps->time_to_leave)
1267 return TRUE; 1345 return TRUE;
1268 } 1346 }
@@ -1273,10 +1351,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1273 if (u > 0) 1351 if (u > 0)
1274 { 1352 {
1275 tmp = g_strdup_printf ("%u", u); 1353 tmp = g_strdup_printf ("%u", u);
1276 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1354 if (NULL != tmp)
1277 EXTRACTOR_METATYPE_VIDEO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1355 {
1278 (const char *) tmp, strlen (tmp) + 1); 1356 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1279 g_free (tmp); 1357 "gstreamer",
1358 EXTRACTOR_METATYPE_VIDEO_BITRATE,
1359 EXTRACTOR_METAFORMAT_UTF8,
1360 "text/plain",
1361 (const char *) tmp,
1362 strlen (tmp) + 1);
1363 g_free (tmp);
1364 }
1280 if (ps->time_to_leave) 1365 if (ps->time_to_leave)
1281 return TRUE; 1366 return TRUE;
1282 } 1367 }
@@ -1285,10 +1370,17 @@ send_video_info (GstDiscovererVideoInfo *info,
1285 if (u > 0) 1370 if (u > 0)
1286 { 1371 {
1287 tmp = g_strdup_printf ("%u", u); 1372 tmp = g_strdup_printf ("%u", u);
1288 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1373 if (NULL != tmp)
1289 EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1374 {
1290 (const char *) tmp, strlen (tmp) + 1); 1375 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1291 g_free (tmp); 1376 "gstreamer",
1377 EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE,
1378 EXTRACTOR_METAFORMAT_UTF8,
1379 "text/plain",
1380 (const char *) tmp,
1381 strlen (tmp) + 1);
1382 g_free (tmp);
1383 }
1292 if (ps->time_to_leave) 1384 if (ps->time_to_leave)
1293 return TRUE; 1385 return TRUE;
1294 } 1386 }
@@ -1442,8 +1534,11 @@ send_tag_foreach (const GstTagList * tags,
1442 1534
1443 buf = gst_sample_get_buffer (sample); 1535 buf = gst_sample_get_buffer (sample);
1444 gst_buffer_map (buf, &mi, GST_MAP_READ); 1536 gst_buffer_map (buf, &mi, GST_MAP_READ);
1445 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", le_type, 1537 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1446 EXTRACTOR_METAFORMAT_BINARY, mime_type, 1538 "gstreamer",
1539 le_type,
1540 EXTRACTOR_METAFORMAT_BINARY,
1541 mime_type,
1447 (const char *) mi.data, mi.size); 1542 (const char *) mi.data, mi.size);
1448 gst_buffer_unmap (buf, &mi); 1543 gst_buffer_unmap (buf, &mi);
1449 } 1544 }
@@ -1564,7 +1659,8 @@ send_tag_foreach (const GstTagList * tags,
1564 if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '=')) 1659 if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '='))
1565 { 1660 {
1566 new_str = g_strdup_printf ("%s=%s", tag, str); 1661 new_str = g_strdup_printf ("%s=%s", tag, str);
1567 g_free (str); 1662 if (NULL != str)
1663 g_free (str);
1568 str = new_str; 1664 str = new_str;
1569 } 1665 }
1570 } 1666 }
@@ -1572,13 +1668,18 @@ send_tag_foreach (const GstTagList * tags,
1572 default: 1668 default:
1573 break; 1669 break;
1574 } 1670 }
1575 if (!skip) 1671 if ( (! skip) &&
1576 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", le_type, 1672 (NULL != str) )
1577 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1673 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1578 (const char *) str, strlen (str) + 1); 1674 "gstreamer",
1675 le_type,
1676 EXTRACTOR_METAFORMAT_UTF8,
1677 "text/plain",
1678 (const char *) str,
1679 strlen (str) + 1);
1579 } 1680 }
1580 1681 if (NULL != str)
1581 g_free (str); 1682 g_free (str);
1582 g_value_unset (&val); 1683 g_value_unset (&val);
1583 } 1684 }
1584} 1685}
@@ -1730,24 +1831,39 @@ send_toc_tags_foreach (const GstTagList * tags,
1730 /* This is a potential source of invalid characters */ 1831 /* This is a potential source of invalid characters */
1731 /* And it also might attempt to serialize binary data - such as images. */ 1832 /* And it also might attempt to serialize binary data - such as images. */
1732 str = gst_value_serialize (&val); 1833 str = gst_value_serialize (&val);
1733 g_free (str); 1834 if (NULL != str)
1734 str = NULL; 1835 {
1836 g_free (str);
1837 str = NULL;
1838 }
1735 break; 1839 break;
1736 } 1840 }
1737 if (str != NULL) 1841 if (NULL != str)
1738 { 1842 {
1739 topen = g_strdup_printf ("%*.*s<%s>", ps->toc_depth * 2, 1843 topen = g_strdup_printf ("%*.*s<%s>",
1740 ps->toc_depth * 2, " ", tag); 1844 ps->toc_depth * 2,
1741 tclose = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2, 1845 ps->toc_depth * 2, " ", tag);
1742 ps->toc_depth * 2, " ", tag); 1846 tclose = g_strdup_printf ("%*.*s</%s>\n",
1743 1847 ps->toc_depth * 2,
1744 if (ps->toc_print_phase) 1848 ps->toc_depth * 2, " ",
1745 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], 1849 tag);
1746 ps->toc_length - ps->toc_pos, "%s%s%s", topen, str, tclose); 1850 if ( (NULL != topen) &&
1747 else 1851 (NULL != tclose) )
1748 ps->toc_length += strlen (topen) + strlen (str) + strlen (tclose); 1852 {
1749 g_free (topen); 1853 if (ps->toc_print_phase)
1750 g_free (tclose); 1854 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
1855 ps->toc_length - ps->toc_pos,
1856 "%s%s%s",
1857 topen,
1858 str,
1859 tclose);
1860 else
1861 ps->toc_length += strlen (topen) + strlen (str) + strlen (tclose);
1862 }
1863 if (NULL != topen)
1864 g_free (topen);
1865 if (NULL != tclose)
1866 g_free (tclose);
1751 g_free (str); 1867 g_free (str);
1752 } 1868 }
1753 g_value_unset (&val); 1869 g_value_unset (&val);
@@ -1780,11 +1896,17 @@ send_toc_foreach (gpointer data, gpointer user_data)
1780 GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth * 2, " ", 1896 GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth * 2, " ",
1781 gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (start), 1897 gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (start),
1782 GST_TIME_ARGS (stop)); 1898 GST_TIME_ARGS (stop));
1783 if (ps->toc_print_phase) 1899 if (NULL != s)
1784 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s); 1900 {
1785 else 1901 if (ps->toc_print_phase)
1786 ps->toc_length += strlen (s); 1902 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
1787 g_free (s); 1903 ps->toc_length - ps->toc_pos,
1904 "%s",
1905 s);
1906 else
1907 ps->toc_length += strlen (s);
1908 g_free (s);
1909 }
1788 ps->toc_depth++; 1910 ps->toc_depth++;
1789 tags = gst_toc_entry_get_tags (entry); 1911 tags = gst_toc_entry_get_tags (entry);
1790 if (tags) 1912 if (tags)
@@ -1808,13 +1930,18 @@ send_toc_foreach (gpointer data, gpointer user_data)
1808 g_list_foreach (subentries, send_toc_foreach, ps); 1930 g_list_foreach (subentries, send_toc_foreach, ps);
1809 ps->toc_depth--; 1931 ps->toc_depth--;
1810 1932
1811 s = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2, ps->toc_depth * 2, " ", 1933 s = g_strdup_printf ("%*.*s</%s>\n",
1934 ps->toc_depth * 2,
1935 ps->toc_depth * 2, " ",
1812 gst_toc_entry_type_get_nick (entype)); 1936 gst_toc_entry_type_get_nick (entype));
1813 if (ps->toc_print_phase) 1937 if (NULL != s)
1814 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s); 1938 {
1815 else 1939 if (ps->toc_print_phase)
1816 ps->toc_length += strlen (s); 1940 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s);
1817 g_free (s); 1941 else
1942 ps->toc_length += strlen (s);
1943 g_free (s);
1944 }
1818} 1945}
1819 1946
1820 1947
@@ -1838,11 +1965,17 @@ send_info (GstDiscovererInfo * info,
1838 if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0)) 1965 if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0))
1839 { 1966 {
1840 s = g_strdup_printf ("%" GST_TIME_FORMAT, GST_TIME_ARGS (duration)); 1967 s = g_strdup_printf ("%" GST_TIME_FORMAT, GST_TIME_ARGS (duration));
1841 if (s) 1968 if (NULL != s)
1842 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1969 {
1843 EXTRACTOR_METATYPE_DURATION, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1970 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1844 (const char *) s, strlen (s) + 1); 1971 "gstreamer",
1845 g_free (s); 1972 EXTRACTOR_METATYPE_DURATION,
1973 EXTRACTOR_METAFORMAT_UTF8,
1974 "text/plain",
1975 (const char *) s,
1976 strlen (s) + 1);
1977 g_free (s);
1978 }
1846 } 1979 }
1847 1980
1848 if (ps->time_to_leave) 1981 if (ps->time_to_leave)
@@ -1870,21 +2003,25 @@ send_info (GstDiscovererInfo * info,
1870 ps->toc_print_phase = TRUE; 2003 ps->toc_print_phase = TRUE;
1871 ps->toc_length += 1 + strlen (TOC_XML_HEADER); 2004 ps->toc_length += 1 + strlen (TOC_XML_HEADER);
1872 ps->toc = g_malloc (ps->toc_length); 2005 ps->toc = g_malloc (ps->toc_length);
1873 ps->toc_pos = 0; 2006 if (NULL != ps->toc)
1874 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], 2007 {
1875 ps->toc_length - ps->toc_pos, 2008 ps->toc_pos = 0;
1876 "%s", 2009 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
1877 TOC_XML_HEADER); 2010 ps->toc_length - ps->toc_pos,
1878 g_list_foreach (entries, &send_toc_foreach, ps); 2011 "%s",
1879 ps->toc[ps->toc_length - 1] = '\0'; 2012 TOC_XML_HEADER);
1880 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 2013 g_list_foreach (entries, &send_toc_foreach, ps);
1881 EXTRACTOR_METATYPE_TOC, 2014 ps->toc[ps->toc_length - 1] = '\0';
1882 EXTRACTOR_METAFORMAT_C_STRING, 2015 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1883 "application/xml", 2016 "gstreamer",
1884 (const char *) ps->toc, 2017 EXTRACTOR_METATYPE_TOC,
1885 ps->toc_length); 2018 EXTRACTOR_METAFORMAT_C_STRING,
1886 g_free (ps->toc); 2019 "application/xml",
1887 ps->toc = NULL; 2020 (const char *) ps->toc,
2021 ps->toc_length);
2022 g_free (ps->toc);
2023 ps->toc = NULL;
2024 }
1888 } 2025 }
1889 } 2026 }
1890 2027
diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c
index 44a7ba9..20ac08f 100644
--- a/src/plugins/ole2_extractor.c
+++ b/src/plugins/ole2_extractor.c
@@ -584,7 +584,7 @@ history_extract (GsfInput *stream,
584 size_t bsize; 584 size_t bsize;
585 585
586 bsize = strlen (author) + strlen (filename) + 512; 586 bsize = strlen (author) + strlen (filename) + 512;
587 if (NULL != (rbuf = malloc (bsize)) 587 if (NULL != (rbuf = malloc (bsize)))
588 { 588 {
589 if (bsize > 589 if (bsize >
590 snprintf (rbuf, 590 snprintf (rbuf,
@@ -601,7 +601,7 @@ history_extract (GsfInput *stream,
601 } 601 }
602 free (rbuf); 602 free (rbuf);
603 } 603 }
604 } 604 }
605 if (NULL != author) 605 if (NULL != author)
606 free (author); 606 free (author);
607 if (NULL != filename) 607 if (NULL != filename)