mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Rewrap and fix double free bug by leaking a bit.
2008-08-21 Johan Dahlin <johan@gnome.org> * girepository/girepository.c (g_irepository_require): Rewrap and fix double free bug by leaking a bit. svn path=/trunk/; revision=430
This commit is contained in:
parent
c09cf789a0
commit
790ba0d7b0
@ -520,52 +520,65 @@ g_irepository_require (GIRepository *repository,
|
|||||||
|
|
||||||
fname = g_strconcat (namespace, ".typelib", NULL);
|
fname = g_strconcat (namespace, ".typelib", NULL);
|
||||||
|
|
||||||
for (ldir = search_path; ldir; ldir = ldir->next) {
|
for (ldir = search_path; ldir; ldir = ldir->next)
|
||||||
dir = ldir->data;
|
{
|
||||||
full_path = g_build_filename (dir, fname, NULL);
|
Header *header;
|
||||||
mfile = g_mapped_file_new (full_path, FALSE, &error1);
|
|
||||||
if (error1) {
|
full_path = g_build_filename (ldir->data, fname, NULL);
|
||||||
g_clear_error (&error1);
|
mfile = g_mapped_file_new (full_path, FALSE, &error1);
|
||||||
g_free (full_path);
|
if (error1)
|
||||||
continue;
|
{
|
||||||
}
|
g_clear_error (&error1);
|
||||||
typelib = g_typelib_new_from_mapped_file (mfile);
|
g_free (full_path);
|
||||||
typelib_namespace = g_typelib_get_string (typelib, ((Header *) typelib->data)->namespace);
|
continue;
|
||||||
if (strcmp (typelib_namespace, namespace) != 0) {
|
}
|
||||||
g_free (full_path);
|
|
||||||
|
typelib = g_typelib_new_from_mapped_file (mfile);
|
||||||
|
header = (Header *) typelib->data;
|
||||||
|
typelib_namespace = g_typelib_get_string (typelib, header->namespace);
|
||||||
|
|
||||||
|
if (strcmp (typelib_namespace, namespace) != 0)
|
||||||
|
{
|
||||||
|
g_free (full_path);
|
||||||
|
g_set_error (error, G_IREPOSITORY_ERROR,
|
||||||
|
G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
|
||||||
|
"Typelib file %s for namespace '%s' contains "
|
||||||
|
"namespace '%s' which doesn't match the file name",
|
||||||
|
full_path, namespace, typelib_namespace);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typelib == NULL)
|
||||||
|
{
|
||||||
g_set_error (error, G_IREPOSITORY_ERROR,
|
g_set_error (error, G_IREPOSITORY_ERROR,
|
||||||
G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
|
G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
|
||||||
"Typelib file %s for namespace '%s' contains namespace '%s'"
|
"Typelib file for namespace '%s' was not found in search"
|
||||||
" which doesn't match the file name",
|
" path or could not be openened", namespace);
|
||||||
full_path, namespace, typelib_namespace);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_free (fname);
|
g_free (fname);
|
||||||
if (typelib == NULL) {
|
|
||||||
g_free (full_path);
|
|
||||||
g_set_error (error, G_IREPOSITORY_ERROR,
|
|
||||||
G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
|
|
||||||
"Typelib file for namespace '%s' was not found in search"
|
|
||||||
" path or could not be openened", namespace);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* optionally load shared library and attach it to the typelib */
|
/* optionally load shared library and attach it to the typelib */
|
||||||
shlib = ((Header *) typelib->data)->shared_library;
|
shlib = ((Header *) typelib->data)->shared_library;
|
||||||
if (shlib) {
|
if (shlib)
|
||||||
shlib_fname = g_typelib_get_string (typelib, shlib);
|
{
|
||||||
module = g_module_open (shlib_fname, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL);
|
shlib_fname = g_typelib_get_string (typelib, shlib);
|
||||||
if (module == NULL) {
|
module = g_module_open (shlib_fname,
|
||||||
g_free (full_path);
|
G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL);
|
||||||
g_set_error (error, G_IREPOSITORY_ERROR,
|
if (module == NULL)
|
||||||
G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
|
{
|
||||||
"Typelib for namespace '%s' references shared library %s,"
|
g_free (full_path);
|
||||||
" but it could not be openened (%s)",
|
g_set_error (error, G_IREPOSITORY_ERROR,
|
||||||
namespace, shlib_fname, g_module_error ());
|
G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
|
||||||
return NULL;
|
"Typelib for namespace '%s' references shared library "
|
||||||
|
"%s, but it could not be openened (%s)",
|
||||||
|
namespace, shlib_fname, g_module_error ());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_remove (table, namespace);
|
g_hash_table_remove (table, namespace);
|
||||||
register_internal (repository, full_path, typelib);
|
register_internal (repository, full_path, typelib);
|
||||||
|
Loading…
Reference in New Issue
Block a user