Fix Too many timers bug and snprintf format string bug in DnD protocol

Fixes #9628
This commit is contained in:
copilot-swe-agent[bot] 2026-03-09 06:18:55 +00:00 committed by Kovid Goyal
parent 9ee058eaf9
commit e55c4468e5
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 5 deletions

View file

@ -104,7 +104,7 @@ Requesting data is done by sending an escape code of the form::
OSC _dnd_code ; t=r ; MIME type ST
This will request data for the specifid MIME type. The terminal must respond
This will request data for the specified MIME type. The terminal must respond
with a series of escape codes of the form::
OSC _dnd_code ; t=r ; base64 encoded data ST
@ -116,7 +116,7 @@ getting the data, the terminal must send an escape code of the form::
Here POSIX error name is a POSIX symbolic error name such as ``ENOENT`` or
``EIO`` or the value ``EUNKNOWN`` for an unknown error. Note that if a client
sends a request for another MIME type before the data for the revious MIME type
sends a request for another MIME type before the data for the previous MIME type
is completed, the terminal *must* switch over to sending data for the new MIME
type.

View file

@ -164,14 +164,14 @@ flush_pending_payloads(id_type timer_id UNUSED, void *x) {
id_type id = (uintptr_t)x;
Window *w = window_for_window_id(id);
if (w && w->drop.wanted) {
if (!flush_pending(w->id, &w->drop.pending)) check_for_pending_writes();
if (flush_pending(w->id, &w->drop.pending)) check_for_pending_writes();
}
}
static void
queue_payload_to_child(id_type id, PendingData *pending, const char *header, size_t header_sz, const char *data, size_t data_sz, bool as_base64) {
size_t offset = 0;
if (flush_pending(id, pending)) offset = send_payload_to_child(id, header, header_sz, data, data_sz, as_base64);
if (!flush_pending(id, pending)) offset = send_payload_to_child(id, header, header_sz, data, data_sz, as_base64);
if (offset < data_sz || (!offset && !data_sz)) {
ensure_space_for(pending, items, PendingEntry, pending->count + 1, capacity, 32, true);
char *buf = malloc(header_sz + data_sz - offset);
@ -218,7 +218,7 @@ drop_move_on_child(Window *w, const char** mimes, size_t num_mimes, bool is_drop
if (mbuf) {
size_t pos = 0;
for (size_t i = 0; i < w->drop.num_offerred_mimes && pos < mimes_total_size; i++) {
int n = snprintf(mbuf, mimes_total_size - pos, mbuf + pos, "%s ", w->drop.offerred_mimes[i]);
int n = snprintf(mbuf + pos, mimes_total_size - pos, "%s ", w->drop.offerred_mimes[i]);
if (n < 0) break;
pos += n;
}