changeset 26052:b970418bbafe

parsers: set exception when there's too little string data to extract parents Previously we were returning NULL from this function without actually setting up an exception. This fixes that problem, which was detected with cpychecker.
author Augie Fackler <augie@google.com>
date Tue, 18 Aug 2015 16:40:10 -0400
parents af090796cb33
children b68c9d232db6
files mercurial/parsers.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/parsers.c	Tue Aug 18 16:39:26 2015 -0400
+++ b/mercurial/parsers.c	Tue Aug 18 16:40:10 2015 -0400
@@ -481,8 +481,11 @@
 	len = readlen;
 
 	/* read parents */
-	if (len < 40)
+	if (len < 40) {
+		PyErr_SetString(
+			PyExc_ValueError, "too little data for parents");
 		goto quit;
+	}
 
 	parents = Py_BuildValue("s#s#", str, 20, str + 20, 20);
 	if (!parents)