emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs' turn: remove useless if-before-free tests


From: Jim Meyering
Subject: Re: emacs' turn: remove useless if-before-free tests
Date: Tue, 10 Jun 2008 12:25:32 +0200

Jim Meyering <address@hidden> wrote:
> Emanuele Giaquinta <address@hidden> wrote:
>> On Mon, Jun 02, 2008 at 08:14:18AM +0200, Jim Meyering wrote:
>>
>>> Stefan Monnier <address@hidden> wrote:
>>> > Sounds like a good cleanup.
>>> > Feel free to install it unless there's a strong objection.
>>>
>>> Thanks.  I've committed those three change sets.
>>
>> This patch introduced a problem on os x, free on os x is redirected to
>> unexmacosx.c:unexec_free, which does not support a NULL argument in an
>> undumped emacs. The attached patch changes the problematic free call to
>> xfree, as done a few lines below for another pointer.
>>
>> Emanuele
>>
>> diff --git a/src/lread.c b/src/lread.c
>> index e5e77bc..3e0bd1f 100644
>> --- a/src/lread.c
>> +++ b/src/lread.c
>> @@ -1269,7 +1269,7 @@ Return t if the file exists and loads successfully.  
>> */)
>>
>>    UNGCPRO;
>>
>> -  free (saved_doc_string);
>> +  xfree (saved_doc_string);
>>    saved_doc_string = 0;
>>    saved_doc_string_size = 0;
>
> Thanks for catching and fixing that.
> If using xfree (with its MALLOC_BLOCK_INPUT guard) is important there,
> as it seems to be, then your patch also fixes a platform-independent
> race condition bug.
>
> The following change is probably a good idea, too.
> It makes unexec_free (NULL) a no-op, just like free (NULL) is:
>
> 2008-06-08  Jim Meyering  <address@hidden>
>
>       make unexec_free handle NULL the same way free does
>       * unexmacosx.c (unexec_free): Ignore a NULL argument.

If no one objects soon, I'll commit both our changes.

> diff --git a/src/unexmacosx.c b/src/unexmacosx.c
> index 4662260..57f70f8 100644
> --- a/src/unexmacosx.c
> +++ b/src/unexmacosx.c
> @@ -1318,6 +1318,8 @@ unexec_realloc (void *old_ptr, size_t new_size)
>  void
>  unexec_free (void *ptr)
>  {
> +  if (ptr == NULL)
> +    return;
>    if (in_dumped_exec)
>      {
>        if (!ptr_in_unexec_regions (ptr))
> --
> 1.5.6.rc1.23.g2f46




reply via email to

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