Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: Avoid strlen calls after sprintf
- X-seq: zsh-workers 53465
- From: zeurkous@xxxxxxxxxxxxxxx
- To: Oliver Kiddle <opk@xxxxxxx>, Zsh workers <zsh-workers@xxxxxxx>
- Subject: RE: Avoid strlen calls after sprintf
- Date: Sat, 12 Apr 2025 22:41:44 +0000 (UTC)
- Archived-at: <https://zsh.org/workers/53465>
- In-reply-to: <55461-1738028157.576993@J2TS.vueI.SU7s>
- List-id: <zsh-workers.zsh.org>
- References: <55461-1738028157.576993@J2TS.vueI.SU7s>
[Sorry for the late response.]
Haai,
On Tue, 28 Jan 2025 02:35:57 +0100, Oliver Kiddle <opk@xxxxxxx> wrote:
> This change makes use of the return value from sprintf instead of
> calling strlen on the resulting buffer.
That's sensible; however, as sprintf(3) can theoretically[0] return -1,
it's safer to do an error check before using the value for computation.
--zeurkous.
[0] This could actually happen if the format string is somehow invalid;
in that case, the mistake won't trigger alarm bells but silently
add a value of -1 if left unchecked. Eek.
--
Friggin' Machines!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author