zsh-workers
 help / color / mirror / code / Atom feed
From: Philippe Altherr <philippe.altherr@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [BUG] Misplaced quote in %d printf format crashes Zsh
Date: Sat, 8 Jun 2024 23:12:47 +0200	[thread overview]
Message-ID: <CAGdYchthV3bb7mid0epuHdCVm+4mYFKSLRP9qkFH8j=5y6w7cg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

On macOS 14.5 running Zsh 5.9, the following command crashes Zsh:

% zsh -c "printf -v result \" %5'd\""

zsh:printf:1: %5': invalid directive

zsh(41890,0x7ff8450ddfc0) malloc: *** error for object 0x600002c811e0:
pointer being realloc'd was not allocated

zsh(41890,0x7ff8450ddfc0) malloc: *** set a breakpoint in
malloc_error_break to debug

zsh: abort      zsh -c "printf -v result \" %5'd\""

Surprisingly, dropping the -v option, removing the space before the %, or
adding an echo command after the printf command avoid the crash:

% zsh -c "printf \" %5'd\""

zsh:printf:1: %5': invalid directive

 *%*

% zsh -c "printf -v result \"%5'd\""

zsh:printf:1: %5': invalid directive

% zsh -c "printf -v result \" %5'd\"; echo foo"

zsh:printf:1: %5': invalid directive

foo

Philippe

[-- Attachment #2: Type: text/html, Size: 6379 bytes --]

             reply	other threads:[~2024-06-08 21:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08 21:12 Philippe Altherr [this message]
2024-06-08 23:04 ` Mark J. Reed
2024-06-09  0:23   ` Mark J. Reed
2024-06-11  2:24     ` Jun T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGdYchthV3bb7mid0epuHdCVm+4mYFKSLRP9qkFH8j=5y6w7cg@mail.gmail.com' \
    --to=philippe.altherr@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).