aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qreg.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-22 18:08:14 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-22 19:33:48 +0300
commitc293f725e55661ae690b52d5e8339e48b07a6a85 (patch)
treeca4a3162950ec4cdccccd09b6c38175acacbfec6 /src/qreg.c
parentc174f9be70855e89f606547cfa5471942d238038 (diff)
downloadsciteco-c293f725e55661ae690b52d5e8339e48b07a6a85.tar.gz
fixed crashes while setting special Q-Registers with EU (string-building characters)
* The teco_qreg_vtable_t::get_string() method should support returning the length optionally (may be NULL). This already worked with teco_doc_get_string(), even though it wasn't documented, and therefore didn't cause problems with regular Q-Registers.
Diffstat (limited to 'src/qreg.c')
-rw-r--r--src/qreg.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qreg.c b/src/qreg.c
index 061b685..91ee630 100644
--- a/src/qreg.c
+++ b/src/qreg.c
@@ -665,9 +665,6 @@ teco_qreg_bufferinfo_append_string(teco_qreg_t *qreg, const gchar *str, gsize le
return FALSE;
}
-/*
- * NOTE: The `string` component is currently unused on the "*" register.
- */
static gboolean
teco_qreg_bufferinfo_get_string(teco_qreg_t *qreg, gchar **str, gsize *len,
guint *codepage, GError **error)
@@ -684,7 +681,8 @@ teco_qreg_bufferinfo_get_string(teco_qreg_t *qreg, gchar **str, gsize *len,
/*
* NOTE: teco_file_normalize_path() does not change the size of the string.
*/
- *len = teco_ring_current->filename ? strlen(teco_ring_current->filename) : 0;
+ if (len)
+ *len = teco_ring_current->filename ? strlen(teco_ring_current->filename) : 0;
if (codepage)
*codepage = teco_default_codepage();
return TRUE;
@@ -775,7 +773,8 @@ teco_qreg_workingdir_get_string(teco_qreg_t *qreg, gchar **str, gsize *len,
* the return value for str == NULL is still correct.
*/
gchar *dir = g_get_current_dir();
- *len = strlen(dir);
+ if (len)
+ *len = strlen(dir);
if (str)
*str = teco_file_normalize_path(dir);
else
@@ -919,11 +918,12 @@ teco_qreg_clipboard_get_string(teco_qreg_t *qreg, gchar **str, gsize *len,
&str_converted.len, error) == G_IO_STATUS_ERROR)
return FALSE;
+ if (len)
+ *len = str_converted.len;
if (str)
*str = str_converted.data;
else
teco_string_clear(&str_converted);
- *len = str_converted.len;
if (codepage)
*codepage = teco_default_codepage();