bug#81562: [PATCH] Restore current_buffer when window_text_pixel_size fails
Eli Zaretskii <[email protected]> Thu, 06 Aug 2026 07:25:02 +0300
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
> From: Maxim Wayne <[email protected]> > Date: Wed, 5 Aug 2026 20:26:45 +0800 > > The window-text-pixel-size function temporarily switches the > current_buffer pointer; if the function fails, the pointer is not > switched back. > To reproduce: When current_buffer = buf_a while the window displays > buf_b, giving a cons whose cdr is not an integer > as the FROM argument to window-text-pixel-size, the function fails and > current_buffer doesn't switch back to buf_a. > The included test fails on Emacs 30.2 and passes on the patched code. > Please see the attachment for the patch. The patch is against current > master (commit 602cde3). Thanks, but this is not the correct solution. Our conventions are to validate the arguments of the primitives up front, using the various CHECK_* macros (like CHECK_NUMBER, CHECK_BUFFER, etc.), and if those validations fail, signal an error before performing any significant processing (including switching to another buffer). It is true that this primitive fails to perform such checks, but the correct solution is to add them, not to recover from errors the low-level code might signal due to invalid arguments. Would you like to submit a patch along those lines?