Commit Graph

664 Commits

Author SHA1 Message Date
Tobias Mueller
79225a62c0 gthash: free cmph objects
If not done, it would leak the memory as address sanitizer reports:

==1294==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fa7a94b7602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x44c7a7 in __config_new girepository/cmph/cmph_structs.c:11
    #2 0x44aaa7 in cmph_config_new girepository/cmph/cmph.c:291
    #3 0x446fb5 in _gi_typelib_hash_builder_prepare girepository/gthash.c:114
    #4 0x406cf7 in add_directory_index_section girepository/girmodule.c:270
    #5 0x409ee6 in _g_ir_module_build_typelib girepository/girmodule.c:546
    #6 0x404ada in main tools/compiler.c:217
    #7 0x7fa7a70d482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

==4091==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fc20c854602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x44a3f3 in cmph_io_vector_new girepository/cmph/cmph.c:228
    #2 0x44a965 in cmph_io_vector_adapter girepository/cmph/cmph.c:276
    #3 0x446f9f in _gi_typelib_hash_builder_prepare girepository/gthash.c:113
    #4 0x406cf7 in add_directory_index_section girepository/girmodule.c:270
    #5 0x409ee6 in _g_ir_module_build_typelib girepository/girmodule.c:546
    #6 0x404ada in main tools/compiler.c:217
    #7 0x7fc20a47182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
2016-09-12 16:54:53 +02:00
Emmanuele Bassi
597d32df9c docs: Clarify return value documentation
Be a bit more specific than just saying "the transfer".
2016-05-18 23:12:13 +01:00
Emmanuele Bassi
f6ea169530 docs: Fix return value description
The return value of g_callable_info_get_caller_owns() is not a boolean
any more.
2016-05-18 23:10:46 +01:00
Paolo Borelli
50c7ae999c gdump: do not leak gfile objects 2016-05-08 15:35:13 -04:00
Carlos Garnacho
8a08674b33 girepository: Merge overrides with the regular search path
This reverts commit e81c4681cc88a00fcd841c5a68d860d3714b55d7

The GI_TYPELIB_PATH envvar will still allow overriding the default
typelib dir (based on gobject-introspection libdir), but applications
will have the last say about typelib lookup directories. The resulting
lookup order is now:

- Paths added through g_irepository_prepend_search_path()
- Paths in GI_TYPELIB_PATH
- The default gobject introspection lookup dir

This makes g_irespository_prepend_search_path() work as announced
despite environment variables. If any application was relying on
GI_TYPELIB_PATH overriding the paths of this function call (for e.g.
make check, or to be able to run code inside the project tree), it
is encouraged to set up a similar envvar for their application specific
lookup dir, or perform this override through other means.

https://bugzilla.gnome.org/show_bug.cgi?id=765735
2016-05-02 16:20:31 +02:00
Chun-wei Fan
b4df729c61 Fix code style
Make my last patch to this file conform to the code style in the rest
of this file.
2016-03-17 17:39:43 +08:00
Chun-wei Fan
4e43ed8112 cmph/bdz.c: Work Around MSVC 2012 x64 Compiler Bug
Due to an MSVC 2012 x64 compiler issue, the compiler generates bad code
for bdz.c, so the for loop in assign() continues running until the point
i falls below zero, causing an access violation when we try to do
curr_edge=queue[i]; (line 427 in bdz.c).  Address this issue by breaking
out of the loop at the end of it when i reaches 0 after doing the
necessary processing.

https://bugzilla.gnome.org/show_bug.cgi?id=733595
2016-03-16 22:48:18 +08:00
Philip Withnall
ec81889c35 girepository: Fix some memory leaks in gdump.c
These were leaking memory when dumping introspection data from projects
for building their GIR files. That’s generally not a problem, unless
you’re trying to build the project with -fsanitize=address, which causes
the GIR build phase to error out due to leaking memory.

https://bugzilla.gnome.org/show_bug.cgi?id=762653
2016-02-26 08:22:02 +00:00
Colin Walters
569b1dc9a8 Revert "libgirepository: Refuse to run in setuid applications"
This reverts commit 98bb6c91b710a95efe4cfeb303daeec3381b9c98.

It breaks programs simply executed *transitively* from a setuid
binary like the dbus daemon launch helper.

https://bugzilla.redhat.com/show_bug.cgi?id=1285991

Conflicts:
	girepository/girepository.c
2015-12-09 16:17:48 -05:00
Garrett Regier
6b55207f25 girepository: Fix memory leak in g_irepository_get_dependencies()
The transitive_dependencies GHashTable was being leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=758448
2015-11-20 23:02:10 -08:00
Colin Walters
0f0b325d72 repository: Fix format string error in previous commit
Regression from df21d1f362a810f48a23b7c121bf09ce398539c7
2015-10-12 12:15:53 -04:00
Simon Feltman
220fbf35b8 girepository: Use constant time calculation for sections after Object fields
Add "n_field_callbacks" to ObjectBlob which represents the number of object
fields which are also callbacks. This a allows a constant time computation
for accessing sections after fields. Track writing of this field by passing
an extra argument through the girnode writers recursive call structure. This
essentally reverts a portion of commit 7027bb256d0d1ab which added a linear
time computation for accessing sections after fields.
Update typelib validator to also ensure n_field_callbacks is properly set.

https://bugzilla.gnome.org/show_bug.cgi?id=700338
2015-10-10 17:41:24 -04:00
Colin Walters
714414f0af girparser: Avoid a crash with an unset transfer annotation
Spotted by Coverity.

https://bugzilla.gnome.org/show_bug.cgi?id=752549
2015-10-04 12:00:23 -04:00
Colin Walters
3d2f1c2cd3 girepository: Drop executable bits from cmph .[ch] files
No reason for it.

https://bugzilla.gnome.org/show_bug.cgi?id=752931
2015-10-04 11:58:12 -04:00
Colin Walters
5bda8cc0d3 girepository: Add missing include
For previous commit.
2015-09-26 11:51:33 -04:00
Philip Withnall
ba2c4624da gitypeinfo: Expand documentation for g_type_info_is_pointer()
Note that (direction [in]out) parameters are only pointers if the
underlying type being transferred is a pointer, i.e. if the formal
parameter is a pointer to a pointer or deeper.

https://bugzilla.gnome.org/show_bug.cgi?id=720201
2015-09-26 11:37:15 -04:00
Colin Walters
02c64c25d2 libgirepository: Refuse to run in setuid applications
We know of at least one privilege escalation path via
`GI_TYPELIB_PATH`.  I don't want to audit for others.  If someone
shows up with a use case we can talk.

https://bugzilla.gnome.org/show_bug.cgi?id=755472
2015-09-24 11:10:36 -04:00
Jasper St. Pierre
3fa183524e girepository: Remove "optimization" for found prefixes
This optimization is bugged and broken in the case of certain
libraries. GNOME uses a lot of prefixes with "G", so we'll almost always
have found the prefix.

This is specifically a problem for something like GXml.xDocument, which
uses a type name starting with a lower-case letter, which fools the
prefix logic, but we're also fooled by the "G" appearing in GLib and
Gio.

A more sophisticated version of this check would have three passes:
check prefix with type-case, check prefix without type-case, global
search, but this is an edge case and it doesn't feel worth it to write.
2015-07-27 17:21:05 -07:00
Garrett Regier
96deb9ede5 girepository: Support GError exceptions on callbacks
Generalize "throws" attribute to SignatureBlob which can be used by all
callable blob types. Keep FunctionBlob and VFuncBlob throw attributes
around and functional for compatibility. Refactor girwriter.c to write
out throws attribute for all callable types.

Based on a patch by Simon Feltman.

https://bugzilla.gnome.org/show_bug.cgi?id=729543
2015-06-21 13:01:25 -07:00
Garrett Regier
6eaa308869 girepository: Add g_struct_info_find_field()
Add find_field utility function for finding a field info by name.
Beyond convenience, this should be faster than manually using
the get_n_fields and get_field functions because get_field does
an additional iteration for each field to calculate offsets O(n^2).
Thus find_field combines the offset and comparison
computations into a single loop O(n).

Based on a patch by Simon Feltman.
2015-06-21 13:01:25 -07:00
Lionel Landwerlin
355fcd387d scanner/girepository: remove GdkRectangle->CairoRectangleInt automatic conversion
https://bugzilla.gnome.org/show_bug.cgi?id=748832
2015-05-11 16:05:02 +01:00
Garrett Regier
1627d65d0f Fix docs for g_irepository_get_shared_library()
https://bugzilla.gnome.org/show_bug.cgi?id=744536
Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
2015-03-10 20:47:59 +01:00
Philip Withnall
e222ca2ef2 girepository: Add g_irepository_get_immediate_dependencies()
g_irepository_get_dependencies() is supposed to return the transitive
closure of all dependencies of the given namespace. However, it just
loads the dependencies field from the typelib, which is supposed to only
list immediate dependencies.

Introduce a new g_irepository_get_immediate_dependencies() which does
this, and rewrite g_irepository_get_dependencies() to build the
transitive closure of all its namespace dependencies. This does not
require loading any new typelibs, as the transitive closure of
dependencies should already have been loaded by g_irepository_require()
or g_irepository_load_typelib().

https://bugzilla.gnome.org/show_bug.cgi?id=743782
2015-02-16 08:49:28 +00:00
Philip Withnall
5389e87a29 girepository: Document semantics of dependencies and includes better
Make it clear that both the dependencies field in the typelib, and the
include elements in the GIR AST, are for immediate dependencies, not
transitive ones.

https://bugzilla.gnome.org/show_bug.cgi?id=743782
2015-02-16 08:49:28 +00:00
Philip Withnall
3128c1e9a5 girepository: Fix NULL return from g_irepository_get_dependencies()
If a typelib had no dependencies, g_irepository_get_dependencies() would
return NULL, rather than an empty NULL-terminated vector.

https://bugzilla.gnome.org/show_bug.cgi?id=743782
2015-02-16 08:48:49 +00:00
Chun-wei Fan
2825bd2edc build: Export Symbols Using Compiler Directives
Use compiler directives for exporting symbols for the build of
libgirepository and also for the test libraries, like what is now done
in GLib and GTK+ so that maintaining a separate .symbols (and .def files)
would not be needed, in which the correct compiler directive is determined
during configure time.  Drop all the .def files and the .symbols file as
we would not be using them anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=732669
2014-08-15 10:00:38 +08:00
Chun-wei Fan
265ea792c1 girepository: Add Header for Version Macros
This adds a header to the girepository library, which is then included
either directly or indirectly by the other headers so that all the public
symbols (and the 2 symbols in gitypelib-internal.h used by the tools) are
decorated by a macro, that can later be used to export the symbols and also
to be used to display compile-time warnings for usage of deprecated APIs,
which is like what is now being done in GLib (and GTK+, Clutter, and so
on).

This marks the first step that we begin to stop depending on the .symbols/
.def files to export the symbols.

https://bugzilla.gnome.org/show_bug.cgi?id=732669
2014-08-15 09:45:41 +08:00
Chun-wei Fan
adc6f08ff7 girepository: Include config.h First in All Sources
This includes config.h in all the C-sources of girepository so that we can
get the correct export directive from config.h during compile time and
therefore export the symbols as necessary, like what GLib and GTK+ is
currently doing.

https://bugzilla.gnome.org/show_bug.cgi?id=732669
2014-07-07 09:24:12 +08:00
Giovanni Campagna
9921571eb0 Parse and expose ownership transfer for instance parameters
Knowing the ownership transfer for instance parameters is
necessary for correct memory management of functions which
"eat" their instance argument, such as g_dbus_method_invocation_return_*.
Parse this information from the gir file and store in the
typelib, and then provide new API on GICallableInfo to
retrieve this.

https://bugzilla.gnome.org/show_bug.cgi?id=729662
2014-07-03 10:31:17 +02:00
Philip Withnall
d2514073b9 gibaseinfo: Expand g_base_info_iterate_attributes() documentation
Clarify what an attribute is, in response to a question on
gir-devel-list.

https://bugzilla.gnome.org/show_bug.cgi?id=732078
2014-06-23 09:36:01 +01:00
Ryan Lortie
c0dab09f95 girepository: change giarginfo docs
Clarify the meaning of 'may be null' in the docs: it refers to the value
of the argument itself, not the reference to the argument.

https://bugzilla.gnome.org/show_bug.cgi?id=660879
2014-05-14 14:58:44 -04:00
Ryan Lortie
45e28fa698 compiler: girparser: parse 'nullable' attribute
Parse the 'nullable' attribute on parameters and function return types.

Additionally, tweak the meaning of the 'allow-none' attribute.  We now
only treat it as equivalent to 'nullable' for non-out parameters.  For
out parameters, we treat it to mean the same as the already-recognised
'optional' parameter (which we only recently started actually using).

https://bugzilla.gnome.org/show_bug.cgi?id=660879
2014-05-06 08:18:41 -04:00
Ryan Lortie
6d1df44ff7 girepository: ArgBlob: rename allow_none parameter
Rename the "allow_none" parameter on internal/private structure ArgBlob
to "nullable".

This is a straight rename with no other changes.

https://bugzilla.gnome.org/show_bug.cgi?id=660879
2014-05-06 08:18:41 -04:00
Simon Feltman
cf4fb6a0fe g-ir-compiler: Add support for callback fields on GObjects
Use ParseState enum instead of a boolean for the ParseContexts embedded_type
flag. This allows specific tracking of the embedded type currently being
parsed which can now either be STATE_STRUCT_FIELD or STATE_CLASS_FIELD (or
allow for future expansion). Add ParseState::STATE_NONE as the default for
this field.

Fix GObject FieldBlob validation to take into account the sizeof
CallbackBlobs (copied from the struct validator).

Add static g_object_info_get_field_offset which parallels
g_struct_info_get_field_offset which is needed since callback fields may
vary in size.

https://bugzilla.gnome.org/show_bug.cgi?id=725198
2014-02-27 13:51:18 -08:00
Rico Tzschichholz
90a99b4fcc giobjectinfo: Add missing transfer annotation to find_signal () 2014-01-23 17:19:41 +01:00
Ryan Lortie
f76e4ef683 typelib compiler: properly initialise memory
The typelib compiler was writing uninitialised memory to the output file.

There were two sources of this uninitialised memory: the hash writer included
some uninitialised memory in its output, and the bytes added after the hash
output for padding were also not being initialised.

Fix this by passing the padded size to the hash code writer function and
having that function initialise the entire memory region to zero before
writing.

https://bugzilla.gnome.org/show_bug.cgi?id=721177
2013-12-30 22:31:53 -05:00
Florian Müllner
eb6b6f4fd5 scanner: Support boolean constants
Aliasing TRUE or FALSE is not very common, but done occasionally
for extra clarity. Namely G_SOURCE_REMOVE / G_SOURCE_CONTINUE are
self-explanatory, unlike the "raw" booleans.

https://bugzilla.gnome.org/show_bug.cgi?id=719566
2013-11-29 18:45:31 +00:00
Philip Withnall
4dfcf7bc21 girnode: Fix a NULL pointer deference if a namespace can’t be found
https://bugzilla.gnome.org/show_bug.cgi?id=711541
2013-11-06 11:38:08 +00:00
Giovanni Campagna
67358cdaf4 GIVFuncInfo: allow retrieving the address of an interface vfunc
Don't assume that the parent of a GIVFuncInfo is a GIObjectInfo,
it could be a GIInterfaceInfo, if the vfunc is part of interface
instead of a class.

https://bugzilla.gnome.org/show_bug.cgi?id=688375
2013-10-22 23:33:44 +02:00
Dieter Verfaillie
bb7f8d57c2 docs: fix up reference docs a bit
- require GTK-Doc 1.19
      - remove sgml mode
      - automatically generate gi.types (needs GTK-Doc 1.19)
      - fix https://bugzilla.gnome.org/show_bug.cgi?id=700025
[WIP] - rearange sections a bit
[WIP] - add gi-building, gi-programming sections
[WIP] - mark missing docs with TODO, which is only marginaly
        better than nothing but at least can be grepped :)

https://bugzilla.gnome.org/show_bug.cgi?id=571648
2013-10-10 16:48:51 -04:00
Dieter Verfaillie
a50bfe5ec3 girepository: remove glib-compat
We depend on glib-2.0 >= 2.36.0, so no need to keep a 2.22.X
compatibility symbol around...
2013-10-09 12:48:46 -04:00
Dieter Verfaillie
c87579bbb6 giscanner: fix description field storage in .gir files
GTK-Doc description fields for tags can contain multiple lines and
even multiple paragraphs. Whitespace cannot be preserved in XML
attributes, so we move the "deprecated" description text into
a "<doc-deprecated />" element right next to where we already have
the "<doc />" element. Keep the "deprecated" attribute around for
backwards compatibility though, but set its value to "1" (analogous
to the "writable", "contruct", etc attributes) if the annotated
symbol is marked as deprecated.

While at it, add <doc-version /> and <doc-stability /> which
was not yet available in the .gir files...

This takes care of the "Since:", "Stability:" and "Deprecated:"
GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as
as we already write a "<doc />" child element on "<return-value />".
2013-10-08 20:56:10 +02:00
Dieter Verfaillie
c9b088c24f giscanner: store code before and after comment block
so we can later use them to re-write source files containing
broken GTK-Doc comment blocks where /** is preceded by and/or
*/ is followed by code...
2013-10-08 20:56:07 +02:00
Simon Feltman
67ee43b667 Use case insensitive compare for signal "when" attribute
Update parser to use g_ascii_strcasecmp instead of strcmp. This fixes
incorrect flags being set when the incomming gir is using lowercase values
for the "when" attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=709462
2013-10-05 01:43:09 -07:00
Simon Kågedal Reimer
236d3375c6 g_irepository_dump: Update doc to match code
The input file no longer only consists of names of get_type-functions,
instead begins with either "get-type:" or "error-quark:".

https://bugzilla.gnome.org/show_bug.cgi?id=701639
2013-06-05 13:43:12 -04:00
Christian Persch
55efc6e90e Add printf attribute
This fixes a compiler warning when using -Wmissing-format-attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=698521
2013-05-05 22:56:21 +02:00
Colin Walters
273178600c typelib: Also ignore typelibs with empty c:prefix
As seen in xlib.gir at least; this is something we should probably ban
though.

https://bugzilla.gnome.org/697759
2013-04-15 09:26:38 -04:00
Colin Walters
2e4e98c978 girparser: Also honor legacy c:prefix
vala generates this, and we need to honor it now that we're using the
c:prefix as an optimization when searching for gtypes.

https://bugzilla.gnome.org/697759
2013-04-15 09:26:26 -04:00
Colin Walters
5bea9385b0 gitypelib: And another fix for empty strings 2013-04-08 15:32:15 -04:00
Colin Walters
d0462e6a3c typelib: Fix logic error in previous commit 2013-04-08 14:44:32 -04:00