]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.2.0770: dict_add_dict() has inconsistent ownership on failure v9.2.0770
authorChristian Brabandt <cb@256bit.org>
Thu, 2 Jul 2026 19:30:45 +0000 (19:30 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 2 Jul 2026 19:30:45 +0000 (19:30 +0000)
commit12dbe788d461f7f01a908e9e9ecc844f85d71cb4
tree2170ac8832dd45c29743166fa8a5e75137215246
parent7f6fd6be897485130a595536f095370e48e4c6f2
patch 9.2.0770: dict_add_dict() has inconsistent ownership on failure

Problem:  dict_add_dict() frees the passed dict on one failure path
          (when dict_add() fails) but not on the other (when
          dictitem_alloc() fails), so a caller cannot tell whether it
          still owns the dict after a failure.  Callers that unref the
          dict on failure (e.g. in window.c) then double-free it when
          dict_add() fails.
Solution: Make the failure contract consistent: on failure leave the
          passed dict untouched and owned by the caller; only take a
          reference on success.

related: #20668

Supported by AI.

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/dict.c
src/version.c