| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
Move the preallocation into the GString struct,
and add g_string_init and g_string_clear to
enable on-stack use of GString.
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| | |
Use 'write' with 'count' <= max value of its return type
Closes #2883
See merge request GNOME/glib!3200
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Limit `count` so that `write` can properly report the number of written bytes.
Limits:
- POSIX: `SSIZE_MAX`
- Windows: `INT_MAX`
Fixes: #2883
|
|\ \
| |/
|/|
| |
| | |
Some GString optimizations
See merge request GNOME/glib!3199
|
| | |
|
| |
| |
| |
| |
| | |
We don't need a private inline helper
for this anymore.
|
| |
| |
| |
| | |
This lets us use the optimized inline call.
|
| |
| |
| |
| | |
Test the inline version too.
|
| |
| |
| |
| |
| | |
This is another very commonly used
GString function.
|
| |
| |
| |
| |
| | |
Test the inline versions too, and test
passing -1 for len.
|
| |
| |
| |
| | |
We should check the resulting string too.
|
| |
| |
| |
| |
| |
| | |
Add static inline versions of these functions
that boil down to just an memcpy. ag_string_append_len
is used quite a bit in GMarkup and GTK's css parser.
|
| |
| |
| |
| | |
This is the case we optimize for.
|
| |
| |
| |
| |
| | |
Split off g_string_expand, and inline just
the size check.
|
|\ \
| |/
|/|
| |
| |
| |
| | |
gregex: Prevent invalid memory access for unmatched subpatterns
Closes #2881
See merge request GNOME/glib!3194
|
| |
| |
| |
| |
| |
| |
| |
| | |
Based on a test by Emmanuel Pacaud.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2881
|
|\ \
| |/
|/|
| |
| |
| |
| | |
Revert "Rename user data parameters to user_data"
Closes #2827
See merge request GNOME/glib!3111
|
| |
| |
| |
| | |
Calling a callback parameter "user_data" implicitly adds the "closure" attribute in the documentation which is wrong for callbacks.
|
| |
| |
| |
| | |
This reverts commit 1422e5f81241650c634413911e92d23495692545. The renaming of parameters implicitly introduced "closure" annotations in the documentation which are wrong on callbacks.
|
| |
| |
| |
| | |
This reverts commit da7a31a052614edd2cc87518585ff371cbb0f204. The renaming of parameters implicitly introduced "closure" annotations in the documentation which are wrong on callbacks.
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
garray: Update NULL termination after copying array content
Closes #2877
See merge request GNOME/glib!3190
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
ptr_array_new(len, ., TRUE) ensures that there are at least len+1
elements in pdata, and that pdata[0] is null, but leaves the rest of
pdata uninitialized. After copying the array data into pdata[1] to
pdata[len-1] inclusive, we still need to make sure pdata[len] is a
null terminator.
Note that if len is 0, then pdata is not guaranteed to be non-null. If
it's null, then we can't add null-termination to it until its size
is updated.
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2877
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
tests: Improve error message if setting max processes to 1 fails
See merge request GNOME/glib!3191
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This has historically failed on Debian autobuilders, and as a result we
have had a patch for a long time that turned a failure here into a
g_test_skip(). It's not clear whether this still happens, so I'm now
assessing whether the patch can be dropped; but if the prlimit() call
can fail for whatever reason, it would be useful for the error message
to say what limit we were trying to set.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
garray: Avoid calling memcpy with no items
See merge request GNOME/glib!3192
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`memcpy(NULL, ., n)` and `memcpy(., NULL, n)` are undefined behaviour,
even if *n* is zero.
When len is 0 here, callers are allowed to pass in null data, and
GPtrArray also does not guarantee to have allocated rarray->pdata yet.
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
|/ / |
|
|/
|
|
|
|
|
| |
We cannot use `gvisibility_h` for different visibility header files; you
never know when you're going to refer to the variable again, and
projects might end up needing to retrieve the variable contents—like,
for instance, gobject-introspection using glib as a subproject.
|
|\
| |
| |
| |
| |
| |
| | |
gutils: Avoid possible leaks in g_find_program_for_path()
Closes #2871
See merge request GNOME/glib!3183
|
| |
| |
| |
| |
| |
| | |
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2871
|
|\ \
| |/
|/|
| |
| | |
garray: Add g_ptr_array_sort_values[_with_data]() wrappers
See merge request GNOME/glib!3155
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Historically GPtrArray made possible to compare pointers of pointers values
that it holds, however this is inconvenient in most cases as it requires
wrapper functions and not friendly castings.
So, add two functions that allow to perform the comparisons between the
pointer values that a GPtrArray holds following the same syntax that we
share everywhere in the codebase.
|
| |
| |
| |
| | |
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2857
|
| |
| |
| |
| |
| |
| |
| |
| | |
This should shut Coverity up.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Coverity CID: #1502194
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If a variant is trusted, that means all its children are trusted, so
ensure that their checked offsets are set as such.
This allows a lot of the offset table checks to be avoided when getting
children from trusted serialised tuples, which speeds things up.
No unit test is included because this is just a performance fix. If
there are other slownesses, or regressions, in serialised `GVariant`
performance, the fuzzing setup will catch them like it did this one.
This change does reduce the time to run the oss-fuzz reproducer from 80s
to about 0.7s on my machine.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2841
oss-fuzz#54314
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When dereferencing the first entry in the offset table for a tuple,
check that it doesn’t fall outside the bounds of the variant first.
This prevents an out-of-bounds read from some non-normal tuples.
This bug was introduced in commit 73d0aa81c2575a5c9ae77d.
Includes a unit test, although the test will likely only catch the
original bug if run with asan enabled.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2840
oss-fuzz#54302
|
|\ \
| | |
| | |
| | |
| | | |
garray: Add more G(Ptr)Array constructors to take or copy C arrays
See merge request GNOME/glib!3128
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
Make it easy to handle C arrays using GArray API stealing data from other
sources.
|
| | |
| | |
| | |
| | |
| | | |
This is probably ignored for saving space because of padding optimizations,
but since we want this value to be either 0 or 1, this enforces this too.
|
| | |
| | |
| | |
| | |
| | |
| | | |
It allows to create a GPtrArray from a null-terminated C array computing its
size and in case performing copies of the its values using the provided
GCopyFunc.
|
| | |
| | |
| | |
| | |
| | | |
It makes it easier (and more optimized) to create a GPtrArray from a C-style
array of pointers, in case using a GCopyFunc to duplicate the elements.
|
| | |
| | |
| | |
| | |
| | | |
Similar to g_ptr_array_new_take() but it also computes the length of a
zero-terminated array.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
GPtrArray is a nice interface to handle pointer arrays, however if a classic
array needs to be converted into a GPtrArray is currently needed to manually
go through all its elements and do new allocations that could be avoided.
So add g_ptr_array_new_take() which steals the data from an array of
pointers and allows to manage it using the GPtrArray API.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
musl doesn’t define them itself, presumably because they’re not defined
in POSIX. glibc does define them. Thankfully, the values used in glibc
match the values used internally in other musl macros.
Define the values as a fallback. As a result of this, we can get rid of
the `g_assert_if_reached()` checks in `siginfo_t_to_wait_status()`.
This should fix catching signals from a subprocess when built against
musl.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #2852
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
glib/tests: Add test to check that we abort on low-memory
See merge request GNOME/glib!2992
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
In case we're out of memory we should abort after having printed an error
message, this is similar to crashing but not exactly the same, so ensure
we exit for SIGABRT and not because of a SIGSEV.
We use a test wrapper to ensure that both the exit code and the stderr
match what we expected.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
a79c6af23eff5ee978db62e048828c9a992a1261 uses errno without the required
header.
|