Fix crash when saving device information on preference

i9cf
Mamoru TASAKA 3 years ago
parent 10361fb485
commit ecd0a7b795

@ -0,0 +1,64 @@
From 9723c65d0295baedeb6ee4cb85b35ab51ef22376 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Mon, 22 Nov 2021 17:04:36 +0900
Subject: [PATCH] GnomeCmdData::save_devices: place GVariantBuilder structure
on stack initially
As written on:
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib-GVariant.html#g-variant-builder-new
when calling g_variant_builder_init(), GVariantBuilder structure must be placed on stack first
and the reference to the memory must be passed to the function, instead of
passing nullptr.
---
src/gnome-cmd-data.cc | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 51407cc..b38f96a 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1722,23 +1722,24 @@ void GnomeCmdData::save_devices()
devices = gnome_cmd_con_list_get_all_dev (gnome_cmd_data.priv->con_list);
if (devices && g_list_length(devices) > 0)
{
- GVariantBuilder *gVariantBuilder = nullptr;
+ GVariantBuilder gVariantBuilder;
+ gboolean device_added_p = false;
for (; devices; devices = devices->next)
{
auto *device = GNOME_CMD_CON_DEVICE (devices->data);
if (device && !gnome_cmd_con_device_get_autovol (device))
{
- if (!gVariantBuilder)
+ if (!device_added_p)
{
- g_variant_builder_init (gVariantBuilder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init (&gVariantBuilder, G_VARIANT_TYPE_ARRAY);
}
-
+ device_added_p = true;
gchar *icon_path = g_strdup (gnome_cmd_con_device_get_icon_path (device));
if (!icon_path || icon_path[0] == '\0')
icon_path = g_strdup ("");
- g_variant_builder_add (gVariantBuilder, GCMD_SETTINGS_DEVICES_FORMAT_STRING,
+ g_variant_builder_add (&gVariantBuilder, GCMD_SETTINGS_DEVICES_FORMAT_STRING,
gnome_cmd_con_device_get_alias (device),
gnome_cmd_con_device_get_device_fn (device),
gnome_cmd_con_device_get_mountp (device),
@@ -1747,9 +1748,9 @@ void GnomeCmdData::save_devices()
}
}
- if (gVariantBuilder)
+ if (device_added_p)
{
- devicesToStore = g_variant_builder_end (gVariantBuilder);
+ devicesToStore = g_variant_builder_end (&gVariantBuilder);
g_settings_set_value(options.gcmd_settings->general, GCMD_SETTINGS_DEVICES, devicesToStore);
return;
}
--
2.33.1

@ -13,7 +13,7 @@
%global update_po 0 %global update_po 0
%global if_pre 0 %global if_pre 0
%global use_gcc_strict_sanitize 0 %global use_gcc_strict_sanitize 1
%global use_release 1 %global use_release 1
%global use_gitbare 0 %global use_gitbare 0
@ -41,7 +41,7 @@
%global shortver 1.12 %global shortver 1.12
%global fullver %{shortver}.3.1 %global fullver %{shortver}.3.1
%global mainrel 1 %global mainrel 2
%if 0%{?use_release} >= 1 %if 0%{?use_release} >= 1
%global fedorarel %{?prever:0.}%{mainrel}%{?prever:.%{prerpmver}} %global fedorarel %{?prever:0.}%{mainrel}%{?prever:.%{prerpmver}}
@ -87,6 +87,7 @@ Source2: create-gcmd-git-bare-tarball.sh
Source10: mimeedit-svn%{mimeedit_rev}.sh Source10: mimeedit-svn%{mimeedit_rev}.sh
Patch1: gnome-commander-1.6.0-path-fedora-specific.patch Patch1: gnome-commander-1.6.0-path-fedora-specific.patch
# Must send to be upstream # Must send to be upstream
Patch101: 0001-GnomeCmdData-save_devices-place-GVariantBuilder-stru.patch
BuildRequires: gcc-c++ BuildRequires: gcc-c++
%if 0%{?use_gcc_strict_sanitize} %if 0%{?use_gcc_strict_sanitize}
@ -192,12 +193,34 @@ git config user.name "%{name} Fedora maintainer"
git config user.email "%{name}-owner@fedoraproject.org" git config user.email "%{name}-owner@fedoraproject.org"
%if 0%{?use_release} %if 0%{?use_release}
cat > .gitignore <<EOF
Makefile.in
*/Makefile.in
*/*/Makefile.in
ChangeLog-*
INSTALL
aclocal.m4
config.guess
config.h.in
config.sub
configure
compile
depcomp
install-sh
ltmain.sh
m4
missing
test-driver
ylwrap
EOF
git add . git add .
git commit -m "base" -q git commit -m "base" -q
%endif %endif
%patch1 -p1 -b .path %patch1 -p1 -b .path
git commit -m "Apply Fedora specific path configuration" -a git commit -m "Apply Fedora specific path configuration" -a
cat %PATCH101 | git am
%if 0%{use_autotool} > 0 %if 0%{use_autotool} > 0
( export NOCONFIGURE=1 ; sh autogen.sh ) ( export NOCONFIGURE=1 ; sh autogen.sh )
@ -365,6 +388,9 @@ popd
%{_datadir}/pixmaps/%{name}/ %{_datadir}/pixmaps/%{name}/
%changelog %changelog
* Mon Nov 22 2021 Mamoru TASAKA <mtasaka@fedoraproject.org> - 4:1.12.3.1-2
- Fix crash when saving device information on preference
* Mon Nov 22 2021 Mamoru TASAKA <mtasaka@fedoraproject.org> - 4:1.12.3.1-1 * Mon Nov 22 2021 Mamoru TASAKA <mtasaka@fedoraproject.org> - 4:1.12.3.1-1
- 1.12.3.1 - 1.12.3.1

Loading…
Cancel
Save