backport main: Fix memory leak when a save fails
This commit is contained in:
parent
b2d66ddaa6
commit
132ff9719b
75
0002-main-Fix-memory-leak-when-a-save-fails.patch
Normal file
75
0002-main-Fix-memory-leak-when-a-save-fails.patch
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
From 8de9164be0e4670cd8f3df3c9207a7555228efbf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bastien Nocera <hadess@hadess.net>
|
||||||
|
Date: Thu, 23 Aug 2018 13:50:49 +0200
|
||||||
|
Subject: [PATCH] main: Fix memory leak when a save fails
|
||||||
|
|
||||||
|
and simplify the flow of that function.
|
||||||
|
|
||||||
|
From https://bugs.launchpad.net/ubuntu/+source/fprintd/+bug/1745455/comments/7
|
||||||
|
---
|
||||||
|
src/file_storage.c | 22 +++++++++++-----------
|
||||||
|
1 file changed, 11 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/file_storage.c b/src/file_storage.c
|
||||||
|
index 6b153ef..1c88be7 100644
|
||||||
|
--- a/src/file_storage.c
|
||||||
|
+++ b/src/file_storage.c
|
||||||
|
@@ -95,16 +95,16 @@ int file_storage_print_data_save(struct fp_print_data *data,
|
||||||
|
enum fp_finger finger, const char *username)
|
||||||
|
{
|
||||||
|
GError *err = NULL;
|
||||||
|
- char *path, *dirpath, *buf;
|
||||||
|
+ char *path, *dirpath;
|
||||||
|
size_t len;
|
||||||
|
int r;
|
||||||
|
char *base_store = NULL;
|
||||||
|
+ char *buf = NULL;
|
||||||
|
|
||||||
|
r = file_storage_get_basestore_for_username(username, &base_store);
|
||||||
|
|
||||||
|
- if (r < 0) {
|
||||||
|
- return r;
|
||||||
|
- }
|
||||||
|
+ if (r < 0)
|
||||||
|
+ goto out;
|
||||||
|
|
||||||
|
len = fp_print_data_get_data(data, (guchar **) &buf);
|
||||||
|
if (!len) {
|
||||||
|
@@ -115,27 +115,27 @@ int file_storage_print_data_save(struct fp_print_data *data,
|
||||||
|
path = __get_path_to_print(fp_print_data_get_driver_id(data), fp_print_data_get_devtype(data), finger, base_store);
|
||||||
|
dirpath = g_path_get_dirname(path);
|
||||||
|
r = g_mkdir_with_parents(dirpath, DIR_PERMS);
|
||||||
|
+ g_free(dirpath);
|
||||||
|
if (r < 0) {
|
||||||
|
- g_free(base_store);
|
||||||
|
g_free(path);
|
||||||
|
- g_free(dirpath);
|
||||||
|
- return r;
|
||||||
|
+ goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
//fp_dbg("saving to %s", path);
|
||||||
|
g_file_set_contents(path, buf, len, &err);
|
||||||
|
- free(buf);
|
||||||
|
- g_free(dirpath);
|
||||||
|
g_free(path);
|
||||||
|
if (err) {
|
||||||
|
r = err->code;
|
||||||
|
//fp_err("save failed: %s", err->message);
|
||||||
|
g_error_free(err);
|
||||||
|
/* FIXME interpret error codes */
|
||||||
|
- return r;
|
||||||
|
+ goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return 0;
|
||||||
|
+out:
|
||||||
|
+ g_clear_pointer(&buf, free);
|
||||||
|
+ g_clear_pointer(&base_store, g_free);
|
||||||
|
+ return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int load_from_file(char *path, struct fp_print_data **data)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,12 +1,13 @@
|
|||||||
Name: fprintd
|
Name: fprintd
|
||||||
Version: 0.8.1
|
Version: 0.8.1
|
||||||
Release: 6
|
Release: 7
|
||||||
Summary: Support for consumer fingerprint reader devices
|
Summary: Support for consumer fingerprint reader devices
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Url: http://www.freedesktop.org/wiki/Software/fprint/fprintd
|
Url: http://www.freedesktop.org/wiki/Software/fprint/fprintd
|
||||||
Source0: https://gitlab.freedesktop.org/libfprint/fprintd/uploads/bdd9f91909f535368b7c21f72311704a/%{name}-%{version}.tar.xz
|
Source0: https://gitlab.freedesktop.org/libfprint/fprintd/uploads/bdd9f91909f535368b7c21f72311704a/%{name}-%{version}.tar.xz
|
||||||
|
|
||||||
Patch0001: 0001-device-Fix-client_username-memory-leak.patch
|
Patch0001: 0001-device-Fix-client_username-memory-leak.patch
|
||||||
|
Patch0002: 0002-main-Fix-memory-leak-when-a-save-fails.patch
|
||||||
|
|
||||||
BuildRequires: dbus-glib-devel pam-devel libfprint-devel >= 0.1.0 polkit-devel gtk-doc
|
BuildRequires: dbus-glib-devel pam-devel libfprint-devel >= 0.1.0 polkit-devel gtk-doc
|
||||||
BuildRequires: intltool autoconf automake libtool perl-podlators pkgconfig(systemd)
|
BuildRequires: intltool autoconf automake libtool perl-podlators pkgconfig(systemd)
|
||||||
@ -83,6 +84,9 @@ fi
|
|||||||
%{_mandir}/man1/fprintd.1.gz
|
%{_mandir}/man1/fprintd.1.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Dec 28 2023 liyuanyuan <liyuanyuan@xfusion.com> - 0.8.1-7
|
||||||
|
- main: Fix memory leak when a save fails
|
||||||
|
|
||||||
* Fri Dec 22 2023 liyuanyuan <liyuanyuan@xfusion.com> - 0.8.1-6
|
* Fri Dec 22 2023 liyuanyuan <liyuanyuan@xfusion.com> - 0.8.1-6
|
||||||
- device: Fix client_username memory leak
|
- device: Fix client_username memory leak
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user