Commit Graph

31199 Commits

Author SHA1 Message Date
Michael Catanzaro
7c6b11df2d giochannel: ensure line terminator remains nul-terminated if needed
If the user passes -1 length to g_io_channel_set_line_term() along with
a nul-terminated string, then calls g_io_channel_get_line_term() and
decides to treat the result as nul-terminated rather than checking the
length parameter, then the application will have a problem, because it's
not nul-terminated. That's weird, since the input string was. Let's
ensure the result is consistent: if you pass a nul-terminated string,
the result is nul-terminated. If not, it's not.

Also add a warning to g_io_channel_get_line_term(), since it's very
strange for a gchar * return value to be anything other than a
nul-terminated UTF-8 string. This is an API design bug, but we cannot
fix it.
2024-09-18 01:48:36 +01:00
Michael Catanzaro
a893d622c0 gdatetime: fix double free in format parser
If %#Z is followed by %Z then we accidentally free the tmp variable from
the previous iteration of the loop a second time. Good job to the static
analysis tool (probably Coverity) that found this.

Fortunately it's unlikely that a realistic application would do this.

I've also added a new test that crashes without the fix
2024-09-18 01:48:36 +01:00
Michael Catanzaro
1196ac7af6 gutils: Fix unlikely minor leaks in xdg directory functions
We leak if we have a non-null empty string. This was already fixed for
g_build_user_data_dir() in 1a979ab494
so now fix the others as well.
2024-09-18 01:48:36 +01:00
Michael Catanzaro
f64d4aad6e gvariant-parser: add some comments
I just spent several hours convinced that there was a memory safety
issue in string_parse() and bytestring_parse(). There isn't. (At least,
I think so.) Add some comments to save the next person some time.
2024-09-18 01:48:36 +01:00
Michael Catanzaro
343081becc ggettext: add some comments
Coverity has improperly flagged this code as an instance of CWE-562. The
code is fine, but it's confusing, and humans are likely to wind up
examining it again in the future, so add some comments to explain what's
up.
2024-09-18 01:48:36 +01:00
Michael Catanzaro
12fcbcfa41 gibaseinfo: fully initialize GTypeInfo before registering it 2024-09-18 01:48:36 +01:00
Michael Catanzaro
3936eaaa39 Merge branch 'wip/pwithnall/wfloat-conversion-macos' into 'main'
tests: Add some explicit float → int casts

See merge request GNOME/glib!4277
2024-09-18 00:09:20 +00:00
Philip Withnall
9cb0e9464e
gapplication: Fix a -Wfloat-conversion warning
This introduces no functional changes, but does squash a false positive
warning from `-Wfloat-conversion`:
```
../gio/gapplication.c:462:15: error: implicit conversion turns floating-point number into integer: 'gdouble' (aka 'double') to '_Bool' [-Werror,-Wfloat-conversion]
          if (*(gdouble *) entry->arg_data)
          ~~  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-17 23:55:02 +01:00
Philip Withnall
e888e7d497
tests: Add some explicit float → int casts
This avoids some false positive warnings from `-Wfloat-conversion`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-17 23:54:55 +01:00
Philip Withnall
7a7d8d548a Merge branch 'wfloat-conversion' into 'main'
build: Enable -Wfloat-conversion and fix warnings

See merge request GNOME/glib!4126
2024-09-17 17:57:11 +00:00
Philip Withnall
99c749f4ec Merge branch 'resource-docs' into 'main'
gresource: Convert docs to gi-docgen linking syntax

See merge request GNOME/glib!4243
2024-09-17 13:46:10 +00:00
Philip Withnall
5197d2856c
gresource: Convert docs to gi-docgen linking syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-09-17 14:37:00 +01:00
Philip Withnall
acd4a78173 Merge branch '3465-gresource-error-allocations' into 'main'
gresource: Reduce allocations in g_resources_*() functions

Closes #3465

See merge request GNOME/glib!4242
2024-09-17 13:34:06 +00:00
Philip Withnall
cf0a969101 Merge branch 'wip/pwithnall/3458-scan-build' into 'main'
ci: Fix subproject initialisation for scan-build and coverity

Closes #3458

See merge request GNOME/glib!4273
2024-09-13 15:24:32 +00:00
Philip Withnall
6d408ea76e Merge branch 'macos_arm' into 'main'
Move macOS CI to Apple Silicon runner

Closes #3289

See merge request GNOME/glib!3965
2024-09-12 22:28:10 +00:00
Philip Withnall
683cf0a1ba
tests: Fix a scan-build warning about uninitialised variables
It’s a false positive, but points to a slightly unnecessary use of a
global variable to store something which could be computed per-test.

scan-build thought that arrays of size `n_handlers` could have
uninitialised values accessed in them if `n_handlers` were to change
value part-way through a test (which it didn’t).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 23:25:06 +01:00
Philip Withnall
a0f124e67c
ci: Ignore files in meson-private in scan-build runs
These are typically files generated by the gobject-introspection dumper,
which we don’t want to scan as they are not part of GLib’s runtime code.

For example:
```
/builds/GNOME/glib/_scan_build/meson-private/tmpr3jwvyib/tmp-introspect5dmnb_je/GObject-2.0.c:799:27: warning: Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error') [core.NullDereference]
  799 |       g_printerr ("%s\n", error->message);
      |                           ^~~~~~~~~~~~~~
1 warning generated.
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 23:24:59 +01:00
Philip Withnall
d6be962af9
ci: Fix subproject initialisation for scan-build and coverity
Fixes commit 93271385f9.

Previously the `before_script` from `.build-linux` was used in whole for
these two jobs, but since the `.build-gobject-introspection` template
was also added, the `before_script`s from the two templates need to be
explicitly combined.

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

Fixes: #3458
2024-09-12 23:24:53 +01:00
Philip Withnall
765d199b3a Merge branch 'main' into 'main'
Update Georgian translation

See merge request GNOME/glib!4267
2024-09-12 22:23:46 +00:00
Philip Withnall
8ef85992e0 ci: Re-add contextual links for a FIXME message
To avoid people having to do git archaeology in future to work out why `--wrap-mode=nodownload` is such a good idea.
2024-09-12 22:05:41 +00:00
Philip Withnall
744cdd0f0d Merge branch 'avoid-resource-allocation' into 'main'
resource: Add g_resource[s]_has_children and avoid a pointless allocation

See merge request GNOME/glib!4245
2024-09-12 22:04:39 +00:00
Philip Withnall
b5cab7c6b9
tests: Add g_resource_has_children() test for empty path
To get the code branch coverage up to 100% because it’s not that hard.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 22:53:26 +01:00
René de Hesselle
f9b7898fb7 Move to Apple Silicon based runner
Remove cmake as we no longer need to build ninja. We can use the
official wheel now since the runner's Python is 3.9 (before: 3.8).

Use the same comment regarding '--wrap-mode' as in the other jobs.

Download and use official ccache binary.

Add myself to the 'only' section in .gitlab-ci.yml so I can have
CI in my fork.

Disable a few deprecation warnings due to the much newer SDK of
the Apple Silicon machine.
2024-09-12 23:17:23 +02:00
Philip Withnall
6c80db2c24
ci: Force submodules to be fetched first in VS2017 CI jobs
No idea why this is now suddenly not working.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 21:40:41 +01:00
Matthias Clasen
46fdbb43fa resourcefile: Avoid an allocation
Instead of enumerating the children only to throw them away,
use the new g_resources_has_children() api.
2024-09-12 21:15:55 +01:00
Matthias Clasen
a14241c895 resource: Add g_resource[s]_has_children
These functions avoid allocating the children array when it is
not needed.
2024-09-12 21:15:55 +01:00
Matthias Clasen
cb5209282b resource: Small refactoring
Break out a helper function so we can reuse it in the next commit.
2024-09-12 21:15:55 +01:00
Philip Withnall
0134888d50
build: Bump gvdb subproject dependency and disable tests
This brings in https://gitlab.gnome.org/GNOME/gvdb/-/merge_requests/23,
which is needed for the following few commits.

Unfortunately, one of the other commits it brings in introduces a
sort-of-dependency-loop between GIO and GVDB. To avoid that, we have
to disable the GVDB tests. See
https://gitlab.gnome.org/GNOME/gvdb/-/merge_requests/25 for details.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 21:15:42 +01:00
Philip Withnall
ebdfcf15bf Merge branch 'meson' into 'main'
build: Bump Meson dependency to 1.4.0

See merge request GNOME/glib!4244
2024-09-12 19:06:19 +00:00
Benjamin Gilbert
b2342b1e0c subprojects: Update zlib to 1.3.1
Bug fixes and a security fix for CVE-2022-37434.
2024-09-12 19:15:34 +01:00
Benjamin Gilbert
51e3e7d9ae build: Bump Meson dependency to 1.4.0
Meson 1.5.1 is available in the fd.o SDK and in Debian testing, so the
glib Meson policy says we can update.  Update the minimum only as far as
1.4.0 because we don't yet have a need for 1.5.0.

This allows us to:

- Use file.full_path() to avoid deprecation warnings on str.format(file).
- Set c_std=gnu99,c99 to avoid deprecation warnings with gnu99 on MSVC.

Update all the CI builds to use the latest 1.4.x patch release, 1.4.2.

The FreeBSD runner cannot be updated via `gitlab-ci.yml`, so will be
broken for now.

Similarly, the macOS build will not work unless `-Dc_std=gnu99` is
specified at configure time, due to
https://github.com/mesonbuild/meson/issues/13639.
2024-09-12 19:15:05 +01:00
Philip Withnall
5c2c6ab828 Merge branch 'update-danish-translation' into 'main'
Update Danish translation

See merge request GNOME/glib!4264
2024-09-12 13:51:59 +00:00
Philip Withnall
26f2d54840
gresource: Avoid a gettext lookup on a hot error path
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4242#note_2215991

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

Helps: #3465
2024-09-12 14:42:28 +01:00
Philip Withnall
78884455c4 Merge branch 'fix-string-fn-link' into 'main'
docs(glib): Fix link in string-utils ref

See merge request GNOME/glib!4269
2024-09-12 12:18:44 +00:00
FeRD (Frank Dana)
0bda424669 docs(glib): Fix link in string-utils ref 2024-09-12 06:04:34 -04:00
Benjamin Gilbert
b7203e9406 build: Drop redundant install_tag arguments for headers
All supported versions of Meson will autodetect the tag.
2024-09-11 22:04:39 -07:00
Benjamin Gilbert
cddb084a3f subprojects: Update proxy-libintl to current HEAD
Fix Meson warnings.
2024-09-11 22:04:39 -07:00
NorwayFun
fc069b9ee0 Update ka.po 2024-09-12 01:22:20 +00:00
Philip Withnall
7fb8c80507 Merge branch 'main' into 'main'
Update Russian translation

See merge request GNOME/glib!4262
2024-09-11 22:04:47 +00:00
Philip Withnall
927683ebd9 Merge branch 'update-lt-translation' into 'main'
Updated Lithuanian translation

See merge request GNOME/glib!4256
2024-09-11 09:34:15 +00:00
Ask Hjorth Larsen
6a8468d9e2 Update Danish translation 2024-09-10 22:54:42 +02:00
jtux270
0661cba66c Update Russian translation 2024-09-10 16:46:16 +00:00
Michael Catanzaro
7a1c8d9ba3 Merge branch 'main' into 'main'
gsocket windows: check event before calling WSAEnumNetworkEvents

See merge request GNOME/glib!4261
2024-09-10 13:08:50 +00:00
Silvio Lazzeretti
cfdb60d11d gsocket windows: check event before calling WSAEnumNetworkEvents
The WSAEnumNetworkEvents API is called every time the socket
needs to be checked for status changes. Doing this in an application
with several sockets could generate a high cpu usage since
this call is done for each socket at each iteration of the main loop.
Since there is also a WSAEvent that gets signaled when there is
a change in the status of the socket, checking its status and
calling the WSAEnumNetworkEvents API only if the event is signaled,
can reduce the overall cpu usage.
2024-09-10 09:05:19 +02:00
Philip Withnall
c09ffca226 Merge branch 'ebassi/collate-docs' into 'main'
Collation keys are not encoded in UTF-8

See merge request GNOME/glib!4260
2024-09-09 19:30:39 +00:00
Philip Withnall
b2d8394f17
tests: Add more coverage for GResource overlays
Test more API entry points with overlays.

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

Helps: #3465
2024-09-09 17:39:39 +01:00
Philip Withnall
c5e196f0c0
tests: Add more G_RESOURCE_ERROR_NOT_FOUND unit tests
Add coverage for handling of this situation for more API entry points.

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

Helps: #3465
2024-09-09 17:38:55 +01:00
Philip Withnall
7ed386a10b
tests: Add test for decompression failure in GResource
This was one of the code paths not currently covered by unit tests, so
let’s add a test for it.

This tests what happens when a structurally valid GResource file, but
with a corrupt entry for a compressed file, is loaded.

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

Helps: #3465
2024-09-09 17:37:52 +01:00
Philip Withnall
f1c639c7dc
tests: Re-indent block in resources test
It was slightly over-indented.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-09 17:36:24 +01:00
Philip Withnall
8b13f8854a
gresource: Remove unnecessary errors from g_resources_lookup_data()
This is slightly more involved than the previous couple of commits, as
`g_resource_lookup_data()` can return two errors: one if the resource is
not found, and another if decompression fails.

We want to avoid allocating the `G_RESOURCE_ERROR_NOT_FOUND` error, as
`g_resources_lookup_data()` will be looping through multiple
`GResource`s trying to find the given path, and all but one of them will
return `G_RESOURCE_ERROR_NOT_FOUND`. For a large application, this can
amount to a lot of `GError`s allocated and then immediately freed on
startup.

Use the split from the previous commit to replace the call to
`g_resource_lookup_data()` with its two constituent parts. We can then
handle errors from them separately, ignoring the `NOT_FOUND` error from
`do_lookup()`, while paying attention to any errors from
`resource_to_bytes()`.

This should result in no functional difference to
`g_resources_lookup_data()`, but fewer allocations overall.

Spotted by Christian Hergert.

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

Helps: #3465
2024-09-09 17:36:18 +01:00