[Pcre-svn] [1293] code/trunk: Get rid of gcc -fanalyzer erro…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [1293] code/trunk: Get rid of gcc -fanalyzer error ( though it was probably a false positive).
Revision: 1293
          http://www.exim.org/viewvc/pcre2?view=rev&revision=1293
Author:   ph10
Date:     2021-01-14 16:56:44 +0000 (Thu, 14 Jan 2021)
Log Message:
-----------
Get rid of gcc -fanalyzer error (though it was probably a false positive).


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_auto_possess.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2021-01-10 14:51:53 UTC (rev 1292)
+++ code/trunk/ChangeLog    2021-01-14 16:56:44 UTC (rev 1293)
@@ -9,7 +9,11 @@
 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
------------------------------


Modified: code/trunk/src/pcre2_auto_possess.c
===================================================================
--- code/trunk/src/pcre2_auto_possess.c    2021-01-10 14:51:53 UTC (rev 1292)
+++ code/trunk/src/pcre2_auto_possess.c    2021-01-14 16:56:44 UTC (rev 1293)
@@ -7,7 +7,7 @@


                        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 @@
   list[2] = (uint32_t)(end - code);
   return end;
   }
+
 return NULL;    /* Opcode not accepted */
 }


@@ -1186,12 +1187,16 @@
     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)
           {