guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fixed string corruption bugs (was Guile: What's wrong with this?)


From: Mark H Weaver
Subject: Re: Fixed string corruption bugs (was Guile: What's wrong with this?)
Date: Sat, 07 Jan 2012 10:43:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

> From a8da72937ff4d04e8d39531773cc05e676b2be1c Mon Sep 17 00:00:00 2001
> From: Mark H Weaver <address@hidden>
> Date: Wed, 4 Jan 2012 17:59:27 -0500
> Subject: [PATCH] Fix bugs related to mutation-sharing substrings
>
> * libguile/strings.c (scm_i_is_narrow_string, scm_i_try_narrow_string,
>   scm_i_string_set_x): Check to see if the provided string is a
>   mutation-sharing substring, and do the right thing in that case.
>   Previously, if such a string was passed to these functions, they would
>   behave very badly: while trying to fetch and/or mutate the cell
>   containing the stringbuf, they were actually fetching or mutating the
>   cell containing original shared string.  That's because
>   mutation-sharing substring store the original string in CELL_1,
>   whereas all other strings store the stringbuf there.

I committed this.  Here's an example that segfaulted before these fixes:

  scheme@(guile-user)> (define s (string-copy "hello"))
  scheme@(guile-user)> (define ss (substring/shared s 1 4))
  scheme@(guile-user)> (string-set! ss 0 #\λ)
  Segmentation fault

     Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]