Commit Diff


commit - b129f11e497010def47afd2afb4c1602d8b10d01
commit + 4a6cd10658be56430c4801ea6189fdbf2faf222d
blob - faef9d713ea41f7a77d31961c93f2fd6f753914e
blob + 07004141c4ea65df9faf9ac86dfc2e6223d65afd
--- pdf.c
+++ pdf.c
@@ -623,6 +623,8 @@ act_numb(const HParseResult *p, void *u)
 {
 	const HParsedToken *x = p->ast;
 	int64_t sgn = 1;
+	uint64_t toolarge = -(INT64_MIN+1); // XXX bypass not being able to negate INT64_MIN due to two's complement
+	toolarge += 1;
 
 	if (x->token_type == TT_SEQUENCE) {
 		sgn = H_FIELD_SINT(0);
@@ -632,7 +634,7 @@ act_numb(const HParseResult *p, void *u)
 	assert(sgn == 1 || sgn == -1);
 	switch (x->token_type) {
 	case TT_UINT:
-		if (x->uint > -INT64_MIN)	/* would overflow */
+		if (x->uint > toolarge)	/* would overflow */
 			return NULL;	// XXX structured error type
 		return H_MAKE_SINT(sgn * x->uint);
 	case TT_DOUBLE: