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
This commit is contained in:
Andreas Köhler
2007-05-29 16:24:38 +00:00
parent d8bfaa0572
commit 949e3d5779
3 changed files with 5 additions and 8 deletions

View File

@@ -19,8 +19,5 @@ void gnc_scm_log_error(const gchar *);
void gnc_scm_log_msg(const gchar *); void gnc_scm_log_msg(const gchar *);
void gnc_scm_log_debug(const gchar *); void gnc_scm_log_debug(const gchar *);
/* Special treatment because the string changes in place. */ %newobject gnc_utf8_strip_invalid_strdup;
%typemap(in) gchar * " $1 = SCM_STRING_CHARS($input); " gchar * gnc_utf8_strip_invalid_strdup(const gchar *);
%typemap(freearg) gchar * ""
void gnc_utf8_strip_invalid (gchar *str);

View File

@@ -11,7 +11,7 @@
(re-export gnc-is-debugging) (re-export gnc-is-debugging)
(re-export g-find-program-in-path) (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-warn)
(re-export gnc-scm-log-error) (re-export gnc-scm-log-error)
(re-export gnc-scm-log-msg) (re-export gnc-scm-log-msg)

View File

@@ -71,8 +71,8 @@
;; pick the 1-char tag off from the remainder of the line ;; pick the 1-char tag off from the remainder of the line
(set! tag (string-ref line 0)) (set! tag (string-ref line 0))
(set! value (substring line 1)) (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 ;; now do something with the line
(if (if
(eq? tag #\!) (eq? tag #\!)