changeset 48027:13efd8fdc55f

dirstate: fix parse_dirstate() to error out if NULL entry created Since 83f0e93ec34b "dirstate-item: move the C implementation to the same logic", dirstate_item_from_v1_data() gets more likely to return NULL, and the fuzzer crashes because of that.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 23 Sep 2021 16:44:17 +0900
parents 1b2ee68e85f9
children 448aff4e8dd4
files mercurial/cext/parsers.c
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/parsers.c	Mon Sep 20 20:55:38 2021 +0200
+++ b/mercurial/cext/parsers.c	Thu Sep 23 16:44:17 2021 +0900
@@ -770,6 +770,8 @@
 
 		entry = (PyObject *)dirstate_item_from_v1_data(state, mode,
 		                                               size, mtime);
+		if (!entry)
+			goto quit;
 		cpos = memchr(cur, 0, flen);
 		if (cpos) {
 			fname = PyBytes_FromStringAndSize(cur, cpos - cur);