Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/acme-fontnames2/readme

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


This patch supersedes my acme-fontnames patch.  It:

• Establishes the invariant that fontnames[i] is either nil or
allocated with malloc.  The current code sometimes does
free(static_string) as described in the acme-fontnames patch.  That
patch leaked memory.  This patch should not.

• With the old code for rfget, it seems possible that fontnames[fix]
could get set to a pointer that had been freed.  For example, calling
rfget with save true and name nil would do something like "name =
fontnames[fix]; ⋯; free(fontnames[fix]); fontnames[fix] = name;".  I
do not know if this ever happened in practice, but this patch avoids
the possibility.

• Establishes the convention for rfget that the caller owns rfget's
name parameter; in particular, rfget now does estrdup(name) when
appropriate and the use of rfget around /sys/src/cmd/acme/rows.c:518
no longer does estrdup.  Note that the other uses of rfget are
compatible with this convention and if you decide the other convention
is better (ie, that rfget should own name and callers should do
estrdup), then you need to change the use of rfget around
/sys/src/cmd/acme/exec.c:965 to not free(aa).

• Changes rfget to erealloc (rather than realloc) fontcache.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.