fp-print: Rely on GBytes to align memory

The old workaround is not needed anymore for the GLib version we're
depending on
This commit is contained in:
Marco Trevisan (Treviño)
2026-06-26 13:44:02 +02:00
parent 2d4b1c39e0
commit 1fd4024bd0
+5 -9
View File
@@ -764,7 +764,7 @@ fp_print_deserialize (const guchar *data,
g_autoptr(GVariant) value = NULL; g_autoptr(GVariant) value = NULL;
g_autoptr(GVariant) print_data = NULL; g_autoptr(GVariant) print_data = NULL;
g_autoptr(GDate) date = NULL; g_autoptr(GDate) date = NULL;
guchar *aligned_data = NULL; g_autoptr(GBytes) bytes = NULL;
guint8 finger_int8; guint8 finger_int8;
FpFinger finger; FpFinger finger;
g_autofree gchar *username = NULL; g_autofree gchar *username = NULL;
@@ -786,14 +786,10 @@ fp_print_deserialize (const guchar *data,
* of this function (meaning we don't need to keep the data around. * of this function (meaning we don't need to keep the data around.
*/ */
/* To support GLIB < 2.60 we need to make sure that the memory is aligned correctly. /* We need to copy the backing store for the raw data that we may keep for
* We also need to copy the backing store for the raw data that we may keep for * longer. Using a GBytes also ensures the data is correctly aligned. */
* longer. */ bytes = g_bytes_new (data + 3, length - 3);
aligned_data = g_malloc (length - 3); raw_value = g_variant_new_from_bytes (FPI_PRINT_VARIANT_TYPE, bytes, FALSE);
memcpy (aligned_data, data + 3, length - 3);
raw_value = g_variant_new_from_data (FPI_PRINT_VARIANT_TYPE,
aligned_data, length - 3,
FALSE, g_free, aligned_data);
if (!raw_value) if (!raw_value)
goto invalid_format; goto invalid_format;