[Top][All Lists]

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

Re: Strange code in emacs.c

From: Paul Eggert
Subject: Re: Strange code in emacs.c
Date: Wed, 3 Oct 2018 10:36:35 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Eli Zaretskii wrote:
We have this in 'main':

       emacs_re_safe_alloca = max
         (min (lim - extra, SIZE_MAX) * (min_ratio / ratio),

This always yields MAX_ALLOCA because 'ratio' is always greater than

       int min_ratio = 20 * sizeof (char *);
       int ratio = min_ratio + min_ratio / 3;

Don't we mean to set emacs_re_safe_alloca like this instead:

       emacs_re_safe_alloca = min (lim - extra, SIZE_MAX) / ratio;
       emacs_re_safe_alloca = max (emacs_re_safe_alloca * min_ratio, 

Yes, that sounds better to me too. Also, that SIZE_MAX should be changed to min (SIZE_MAX, PTRDIFF_MAX) to avoid (unlikely) integer-overflow issues.

Should this fix be put into master or into the emacs-26 branch?

reply via email to

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