summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2021-01-14 16:56:44 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2021-01-14 16:56:44 +0000
commit32e83fc2d59413d13039cc31db1558d9c0e3b874 (patch)
tree07ae47253b2690d00d2137169ed0ebd909ea2ce1
parent7ffd23737ca66609ea07f057dcdf5b3be7534844 (diff)
downloadpcre2-32e83fc2d59413d13039cc31db1558d9c0e3b874.tar.gz
Get rid of gcc -fanalyzer error (though it was probably a false positive).
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1293 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r--ChangeLog4
-rw-r--r--src/pcre2_auto_possess.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 58e7ae4..231a24e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,10 @@ zero bytes, because sed varies a lot from system to system and has problems
with binary zeros. This is from Bugzilla #2681. Patch from Jeremie
Courreges-Anglas via Nam Nguyen. This fixes RunGrepTest for OpenBSD.
+2. Compiling with gcc 10.2's -fanalyzer option showed up a hypothetical problem
+with a NULL dereference. I don't think this case could ever occur in practice,
+but I have put in a check in order to get rid of the compiler error.
+
Version 10.36 04-December-2020
------------------------------
diff --git a/src/pcre2_auto_possess.c b/src/pcre2_auto_possess.c
index c64cf85..66064ed 100644
--- a/src/pcre2_auto_possess.c
+++ b/src/pcre2_auto_possess.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016-2020 University of Cambridge
+ New API code Copyright (c) 2016-2021 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -490,6 +490,7 @@ switch(c)
list[2] = (uint32_t)(end - code);
return end;
}
+
return NULL; /* Opcode not accepted */
}
@@ -1186,12 +1187,16 @@ for (;;)
c = *repeat_opcode;
if (c >= OP_CRSTAR && c <= OP_CRMINRANGE)
{
- /* end must not be NULL. */
+ /* The return from get_chr_property_list() will never be NULL when
+ *code (aka c) is one of the three class opcodes. However, gcc with
+ -fanalyzer notes that a NULL return is possible, and grumbles. Hence we
+ put in a check. */
+
end = get_chr_property_list(code, utf, ucp, cb->fcc, list);
-
list[1] = (c & 1) == 0;
- if (compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
+ if (end != NULL &&
+ compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
{
switch (c)
{