From 949e3d577913a7d3fb44668c684f74bbe752ea68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Tue, 29 May 2007 16:24:38 +0000 Subject: [PATCH] Do not change internal scheme strings in place, #389740. This fixes a crash that happened in the QIF import with Guile 1.8 after stripping utf8 violating bytes from the internal null-terminated string of a scheme string, as the length parameter has not been updated and a safety check threw an error from within a critical section at a later stage. Just do not wrap gnc_utf8_strip_invalid but rather gnc_utf8_strip_invalid_strdup. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16135 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/core-utils/core-utils.i | 7 ++----- src/core-utils/core-utils.scm | 2 +- src/import-export/qif-import/qif-file.scm | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/core-utils/core-utils.i b/src/core-utils/core-utils.i index 6c40f09c7c..37ca34f1c8 100644 --- a/src/core-utils/core-utils.i +++ b/src/core-utils/core-utils.i @@ -19,8 +19,5 @@ void gnc_scm_log_error(const gchar *); void gnc_scm_log_msg(const gchar *); void gnc_scm_log_debug(const gchar *); -/* Special treatment because the string changes in place. */ -%typemap(in) gchar * " $1 = SCM_STRING_CHARS($input); " -%typemap(freearg) gchar * "" -void gnc_utf8_strip_invalid (gchar *str); - +%newobject gnc_utf8_strip_invalid_strdup; +gchar * gnc_utf8_strip_invalid_strdup(const gchar *); diff --git a/src/core-utils/core-utils.scm b/src/core-utils/core-utils.scm index 23cf473ad1..ffa9438045 100644 --- a/src/core-utils/core-utils.scm +++ b/src/core-utils/core-utils.scm @@ -11,7 +11,7 @@ (re-export gnc-is-debugging) (re-export g-find-program-in-path) -(re-export gnc-utf8-strip-invalid) +(re-export gnc-utf8-strip-invalid-strdup) (re-export gnc-scm-log-warn) (re-export gnc-scm-log-error) (re-export gnc-scm-log-msg) diff --git a/src/import-export/qif-import/qif-file.scm b/src/import-export/qif-import/qif-file.scm index 00c244cc36..99b090c43e 100644 --- a/src/import-export/qif-import/qif-file.scm +++ b/src/import-export/qif-import/qif-file.scm @@ -71,8 +71,8 @@ ;; pick the 1-char tag off from the remainder of the line (set! tag (string-ref line 0)) (set! value (substring line 1)) - (gnc-utf8-strip-invalid value) ;; changes value in-place - + (set! value (gnc-utf8-strip-invalid-strdup value)) + ;; now do something with the line (if (eq? tag #\!)