summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-01-08 03:41:23 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-01-08 03:41:23 +0000
commit1dda45b32b84127acf96b8f22985560ae7881eb8 (patch)
tree15827049ed3013bd37ab32908ea78e615823fb47
parent3dadbc2b53a665e957192091b115e8387303a54e (diff)
downloadgdk-pixbuf-1dda45b32b84127acf96b8f22985560ae7881eb8.tar.gz
Fix several problems with this function. (fd.o #9560, Yevgen Muntyan)
2007-01-07 Matthias Clasen <mclasen@redhat.com> * xdgmimecache.c (_xdg_mime_cache_list_mime_parents): Fix several problems with this function. (fd.o #9560, Yevgen Muntyan) svn path=/branches/gtk-2-10/; revision=17111
-rw-r--r--gtk/xdgmime/ChangeLog5
-rw-r--r--gtk/xdgmime/xdgmimecache.c20
2 files changed, 18 insertions, 7 deletions
diff --git a/gtk/xdgmime/ChangeLog b/gtk/xdgmime/ChangeLog
index 47474d57b..59b109f8a 100644
--- a/gtk/xdgmime/ChangeLog
+++ b/gtk/xdgmime/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-07 Matthias Clasen <mclasen@redhat.com>
+
+ * xdgmimecache.c (_xdg_mime_cache_list_mime_parents): Fix
+ several problems with this function. (fd.o #9560, Yevgen Muntyan)
+
2007-01-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.7 ===
diff --git a/gtk/xdgmime/xdgmimecache.c b/gtk/xdgmime/xdgmimecache.c
index d08c89b1c..a8035798d 100644
--- a/gtk/xdgmime/xdgmimecache.c
+++ b/gtk/xdgmime/xdgmimecache.c
@@ -850,10 +850,12 @@ _xdg_mime_cache_unalias_mime_type (const char *mime)
char **
_xdg_mime_cache_list_mime_parents (const char *mime)
{
- int i, j, p;
+ int i, j, k, p;
char *all_parents[128]; /* we'll stop at 128 */
char **result;
+ mime = xdg_mime_unalias_mime_type (mime);
+
p = 0;
for (i = 0; _caches[i]; i++)
{
@@ -864,15 +866,19 @@ _xdg_mime_cache_list_mime_parents (const char *mime)
for (j = 0; j < n_entries; j++)
{
- xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * i);
- xdg_uint32_t parents_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * i + 4);
-
+ xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j);
+ xdg_uint32_t parents_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j + 4);
+
if (strcmp (cache->buffer + mimetype_offset, mime) == 0)
{
+ xdg_uint32_t parent_mime_offset;
xdg_uint32_t n_parents = GET_UINT32 (cache->buffer, parents_offset);
-
- for (j = 0; j < n_parents; j++)
- all_parents[p++] = cache->buffer + parents_offset + 4 + 4 * j;
+
+ for (k = 0; k < n_parents && p < 127; k++)
+ {
+ parent_mime_offset = GET_UINT32 (cache->buffer, parents_offset + 4 + 4 * k);
+ all_parents[p++] = cache->buffer + parent_mime_offset;
+ }
break;
}