]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
server: fix edit_file crash on append at end of file (line_start -1) (#24893)
authorPascal <redacted>
Mon, 22 Jun 2026 08:55:28 +0000 (10:55 +0200)
committerGitHub <redacted>
Mon, 22 Jun 2026 08:55:28 +0000 (10:55 +0200)
commitd0f9d2e5ac5d4f51763755958b8f353fed01aaa2
treeacb47d508a1199682dfda780642849005147ac37
parent0ef6f06d553b160d8fc1fba38f5848c7940873a2
server: fix edit_file crash on append at end of file (line_start -1) (#24893)

line_start -1 normalized to n+1, so append inserted at lines.begin() + n + 1,
one past end() -> heap-buffer-overflow in vector::_M_range_insert.

Normalize -1 to n (insert at end()), restrict -1 to append mode and reject it
for replace/delete instead of silently clobbering the last line. Parenthesize
the insert offset so empty-file append computes the position as int first,
avoiding a transient begin() - 1 on a null vector data pointer.
tools/server/server-tools.cpp