1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2026-10-24 00:49:00 +03:00
Commit Graph

32923 Commits

Author SHA1 Message Date
Emmanuele Bassi
ce9c75a083 Trim the allocation of GTypeInstances
The old GSlice API had an automated trim of its magazines if an
allocation happened after a certain amount of time—a configurable toggle
that defaulted to 15 seconds. Trimming in a slab allocator allows to
free up memory and compact the heap.

Trimming does not come for free, so ideally applications allocating a
lot of GTypeInstance objects should trim their memory when it's
convenient for them, rather than on a timer.

See: https://gitlab.gnome.org/GNOME/evolution/-/merge_requests/218
2026-04-10 13:29:55 +01:00
Emmanuele Bassi
5e3bd9b700 Add new probe for trim on GTypeInstance creation
We are going to call malloc_trim(), and it would be good to have a probe
in case we want to instrument the process.
2026-04-10 12:12:45 +01:00
Emmanuele Bassi
59efaf3599 build: Add check for malloc_trim
We are going to use it later.
2026-04-10 12:12:14 +01:00
Philip Withnall
9102d86b75 Merge branch '3854-regex-strlen' into 'main'
gregex: Handle string lengths as unsigned internally

Closes #3854

See merge request GNOME/glib!5137
2026-04-03 14:44:05 +00:00
Michael Catanzaro
6557e9602d Merge branch 'utf8-validation-docs' into 'main'
docs: Clarify UTF-8 validity for functions which accept a length

See merge request GNOME/glib!5136
2026-04-03 08:03:08 -05:00
Philip Withnall
27a6ef1dfa Merge branch 'update-translation-ro-from-main-6c949acc-2f3e-11f1-a069-0a580a8105dd' into 'main'
Update Romanian translation

See merge request GNOME/glib!5140
2026-04-03 10:12:06 +00:00
Antonio Marin
d3dc0fd698 Update Romanian translation 2026-04-03 09:21:08 +00:00
Philip Withnall
5821ef69f2 Merge branch 'update-translation-sl-from-main-380d683c-2ed1-11f1-b2ac-0a580a8303ec' into 'main'
Update Slovenian translation

See merge request GNOME/glib!5138
2026-04-03 00:05:51 +00:00
Martin
766108fd92 Update Slovenian translation 2026-04-02 20:20:04 +00:00
Philip Withnall
11a61bb2a8 gregex: Convert n_offsets and pos to be unsigned
`n_offsets` counts a number of offsets in an array, so should really be
a `size_t` — even though the maximum number of elements in the arrays
used by libpcre2 is `UINT32_MAX`, using `size_t` in GLib helps with
avoiding overflow when we’re growing the array.

`pos` almost always contains a non-negative value. It can contain `-1`
to indicate the match info has been iterated off the end of the results
list. That’s quite a waste of the `int` domain (all negative numbers
except `-1` are invalid), so let’s split the validity out into a boolean
and make `pos` itself unsigned. This fixes a load of signed/unsigned
comparison warnings.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3854
2026-04-02 20:08:10 +01:00
Philip Withnall
c670e0b925 gregex: Handle string lengths as unsigned internally
The `GRegex` external API can’t be changed, and has some string lengths
as `gssize` and some as `int`. But internally, we can consistently
handle them as `size_t` so that the longest possible strings can be
handled without fear of overflow.

This means calling `strlen()` on API boundaries and converting some
internal APIs. We can do this (and change the size of various structs)
because `GRegex` is opaque.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3854
2026-04-02 19:45:30 +01:00
Philip Withnall
75e16025b2 docs: Clarify UTF-8 validity for functions which accept a length
As discussed on
https://gitlab.gnome.org/GNOME/glib/-/issues/3916#note_2724656.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-04-02 19:32:24 +01:00
Philip Withnall
7bc198d24a Merge branch '3919-regex-opts' into 'main'
gregex: Fix use of wrong option flags set for checking for G_REGEX_RAW

Closes #3919 and #3918

See merge request GNOME/glib!5133
2026-04-02 17:24:28 +00:00
Philip Withnall
ae5bd391e2 Merge branch '3918-regex-raw-change-case' into 'main'
gregex: Fix case changing substitutions with G_REGEX_RAW

Closes #3918

See merge request GNOME/glib!5132
2026-04-02 17:12:31 +00:00
Philip Withnall
8fe7f39a1b Merge branch '3917-datetime-validation' into 'main'
gdatetime: Add missing range validation to g_date_time_add_full()

Closes #3917

See merge request GNOME/glib!5131
2026-04-02 16:56:36 +00:00
Philip Withnall
f6ad91154a gregex: Rename the compile_opts members to clarify their types
It’s easy to confuse `compile_opts` (`PCRE2_*` flags) and
`orig_compile_opts` (`GRegexCompileFlags` flags). Rename them to
`pcre2_compile_opts` and `regex_compile_opts`, respectively, to make it
a bit less confusing.

Unfortunately the type checker can’t help us here as the `PCRE2_*` flags
are defined by `pcre2` using `#define`s rather than an `enum`, so
`pcre2_compile_opts` has to stay as a `uint32_t` rather than a more
specific type.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3919
2026-04-02 17:52:20 +01:00
Philip Withnall
92eb6b3719 Merge branch '3916-markup-escape-text' into 'main'
gmarkup: Fix potential one-byte overread in g_markup_escape_text()

Closes #3916

See merge request GNOME/glib!5130
2026-04-02 16:36:14 +00:00
Philip Withnall
4c1966b954 Merge branch '3915-variant-offset-overflow' into 'main'
gvariant: Fix an off-by-one error in an offset comparison

Closes #3915

See merge request GNOME/glib!5129
2026-04-02 16:24:29 +00:00
Philip Withnall
9e3965aeb5 gregex: Fix use of wrong option flags set for checking for G_REGEX_RAW
`GRegex.compile_opts` contains the options using PCRE2’s flags;
`GRegex.orig_compile_opts` contains them in `GRegexCompileFlags` format,
and that’s what we want here.

Spotted by linhlhq as #YWH-PGM9867-194. The suggested fix is theirs, and
the unit test is adapted from their report.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3919
2026-04-02 17:14:10 +01:00
Philip Withnall
49e067570d gregex: Fix case changing substitutions with G_REGEX_RAW
In `G_REGEX_RAW` mode, the input string is treated as a byte array
(basically ASCII) rather than a unichar array. Accordingly, the case
changing code for substitutions needs to operate on bytes with
`G_REGEX_RAW`, rather than operating on unichars.

This fixes a potential buffer overflow when trying to do a case change
on a match of a set of bytes which are a truncated multi-byte UTF-8
encoding at the end of the input buffer.

Spotted by linhlhq as #YWH-PGM9867-193. I adapted their reproducer as
the unit test, but implemented the fix in `gregex.c` independently.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3918
2026-04-02 17:10:21 +01:00
Philip Withnall
0ac0a2a417 gmarkup: Fix potential one-byte overread in g_markup_escape_text()
If the input string (which might be malicious, as the program is
choosing to escape it) ends with 0xc2 (a UTF-8 prefix byte), the code
wasn’t previously checking the input string length was long enough to
contain the following byte before reading it.

Fix that by switching from `g_utf8_get_char()` to
`g_utf8_get_char_validated()`.

Spotted by linhlhq as #YWH-PGM9867-187. Thank you for the suggested fix
and unit test, which have been adapted into this commit.

Also spotted by oss-fuzz after we added a fuzz test for this function.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3916
oss-fuzz#498475244
2026-04-02 16:59:35 +01:00
Philip Withnall
fadb292165 Merge branch 'realloc-alloc-size-order' into 'main'
gmarkup: Swap the argument order for g_realloc_n()

See merge request GNOME/glib!5128
2026-04-02 15:36:20 +00:00
Philip Withnall
a7be15feba gmarkup: Swap the argument order for g_realloc_n()
It turns out that, while it doesn’t document it, gcc does treat the two
arguments to `alloc_size` differently — the first one is assumed to give
the block size argument, and the second the number of blocks.

This doesn’t normally affect code, unless the `-Wcalloc-transposed-args`
warning is enabled (new in GCC 14). Despite its name, this affects all
functions annotated with a two-argument version of `alloc_size()` (not
just `calloc()`), and warns if `sizeof()` is used for the number of
blocks but not for the block size argument.

So, swap the argument orders around in our `g_realloc_n()` calls in
gmarkup, as they were the wrong way round.

Fixes commit 3614d588f and CI failure
https://gitlab.gnome.org/GNOME/glib/-/jobs/6370936.

See:
 - https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Warning-Options.html#index-Wcalloc-transposed-args
 - https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-04-02 16:02:42 +01:00
Philip Withnall
f46b76caa6 Merge branch 'gmarkup-attr-locations' into 'main'
gmarkup: Add api to get attribute locations

See merge request GNOME/glib!5106
2026-04-02 14:47:21 +00:00
Philip Withnall
f8e8046169 Merge branch 'ffi-no-tests' into 'main'
libffi: don't build testsuite when building as subproject

See merge request GNOME/glib!5127
2026-04-02 14:00:32 +00:00
Florian "sp1rit"​
b441405300 libffi: don't build testsuite when building as subproject
Starting with c462700, the libffi pointed to by the libffi wrap
automatically builds the libffi testsuite. This takes time better spent
elsewhere.
2026-04-02 12:40:45 +02:00
Marco Trevisan
876b9fa5de Merge branch 'realloc-annotations' into 'main'
Add missing annotations

See merge request GNOME/glib!5126
2026-04-01 10:10:35 +02:00
Matthias Clasen
eaad30350a Add missing annotations
All of our realloc functions were missing alloc_size
annotations. Fix that, in the hope that it will help
compiler diagnostics and optimization.
2026-03-31 20:16:24 -04:00
Matthias Clasen
3614d588fc gmarkup: Add another location api
Add an api to get locations for attributes. This vastly
improves error reporting, to the point where it is possible
to e.g. can highlight erroneous attrbutes in an SVG editor.

Basic test included.
2026-03-31 11:14:58 -04:00
Matthias Clasen
59421091a0 gmarkup: Small refactoring
Introduce a MarkupLocation struct, and use
it internally.
2026-03-31 11:14:58 -04:00
Matthias Clasen
419a6c61a8 gmarkup: Clarify the docs
Mention that calling the tag start getter outside
of start_element and end_element is undefined.
2026-03-31 07:01:01 -04:00
Philip Withnall
8bb002487d Merge branch 'update-translation-ro-from-main-e1a10342-2ce5-11f1-b0d4-0a580a800486' into 'main'
Update Romanian translation

See merge request GNOME/glib!5123
2026-03-31 10:27:45 +00:00
Antonio Marin
9624f4b106 Update Romanian translation 2026-03-31 09:42:19 +00:00
Michael Catanzaro
28070b88d8 Merge branch 'fuzz-markup-escape-text' into 'main'
fuzzing: Add a fuzz test for g_markup_escape_text()

See merge request GNOME/glib!5117
2026-03-30 10:43:36 -05:00
Philip Withnall
91c0307c68 Merge branch 'bugaevc/gdbus-property-accessors' into 'main'
gio: Apply property accessor annotations to GDBus types

See merge request GNOME/glib!5121
2026-03-30 15:15:20 +00:00
Sergey Bugaev
75768ba482 gio: Apply property accessor annotations to GDBus types
These properties all have their names prefixed with 'g-', in order to
avoid conflicts with property names coming directly from an actual D-Bus
interface that a derived type might want to install. The corresponding
accessor methods are identified by theit full C symbol name, so their
names are not prefixed.

But this resulted in g-ir-scanner being unable to see the connection
between the properties and their accessors. Help it out with explicit
annotations.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2026-03-30 14:30:04 +03:00
Philip Withnall
2a3ca7506a Merge branch 'update-translation-zh_CN-from-main-6a40248c-2bc7-11f1-bcde-0a580a8006ba' into 'main'
Update Chinese (China) translation

See merge request GNOME/glib!5120
2026-03-30 00:00:14 +00:00
luming zh
04da0170c9 Update Chinese (China) translation 2026-03-29 23:31:34 +00:00
Philip Withnall
ededb77ea0 gdatetime: Add missing range validation to g_date_time_add_full()
Otherwise it’s possible to create a non-`NULL` but invalid `GDateTime`,
which breaks all kinds of internal assumptions.

Spotted by linhlhq as #YWH-PGM9867-191. Thanks to them for providing a
suggested fix and a test case, which I have adapted and validated.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3917
2026-03-29 23:46:17 +01:00
Philip Withnall
7f0f7d0870 gdatetime: Factor out a couple of magic constants
This introduces no functional changes, it just makes the code a little
clearer.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-29 23:19:47 +01:00
Philip Withnall
b486f63293 fuzzing: Add a fuzz test for g_markup_escape_text()
This seems like a function which could be used with untrusted inputs, so
it’s probably a good idea to fuzz it.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-03-29 19:51:33 +01:00
Philip Withnall
8338414f65 gvariant: Fix an off-by-one error in an offset comparison
This allows a single byte out-of-bounds read off the end of the
(potentially untrusted) byte array backing a `GVariant` when it’s
being checked for normal form.

I can’t see how this could practically be exploited, but it’s certainly
a security bug as the `GVariant` normal form checking code is supposed
to be robust to malicious inputs.

Spotted by linhlhq as #YWH-PGM9867-190, and fix and reproducer provided
by them too, thanks. Confirmed and turned into a unit test by me.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3915
2026-03-29 19:10:41 +01:00
Philip Withnall
046f9a1d69 Merge branch 'update-translation-sl-from-main-73d3bda0-2b91-11f1-8788-0a580a8007d9' into 'main'
Update Slovenian translation

See merge request GNOME/glib!5116
2026-03-29 17:35:09 +00:00
Martin
616211f9f7 Update Slovenian translation 2026-03-29 17:05:17 +00:00
Philip Withnall
a9e4ebd235 Merge branch 'bugaevc/list-store-no-op' into 'main'
liststore: Micro-optimize no-op bulk operations

See merge request GNOME/glib!5099
2026-03-29 16:20:55 +00:00
Philip Withnall
e7f3ea773a Merge branch 'ptomato-main-patch-72614' into 'main'
gmessages: Remove incorrect callback annotations

See merge request GNOME/glib!5107
2026-03-29 16:20:01 +00:00
Philip Withnall
b515dd03fa Merge branch 'in' into 'main'
g_base64_decode_step: fix documented type of in

See merge request GNOME/glib!5102
2026-03-29 16:19:33 +00:00
Philip Withnall
0278ae8dfe Merge branch 'gmarkup-skip-bom' into 'main'
gmarkup: Skip a byte order mark

Closes #3911

See merge request GNOME/glib!5104
2026-03-29 16:19:06 +00:00
Philip Withnall
f45819746c Merge branch 'test-dbus-config' into 'main'
gtestdbus: Keep config file around until bus daemon exits

See merge request GNOME/glib!5094
2026-03-29 16:16:20 +00:00
Philip Withnall
8d5c1a6c14 Merge branch 'cm/suppress-infinite-loop-warning' into 'main'
gmessages: Avoid -Wanalyzer-infinite-loop warnings in g_error

Closes #3791

See merge request GNOME/glib!5045
2026-03-29 16:15:35 +00:00