[pcre-dev] [Bug 2190] New: This will always return PCRE2_ER…

Top Page
Delete this message
Author: admin
Date:  
To: pcre-dev
New-Topics: [pcre-dev] [Bug 2190] pcre2_substitute will always return PCRE2_ERROR_NOMEMORY if match_data and mcontext both are NULL, [pcre-dev] [Bug 2190] pcre2_substitute will always return PCRE2_ERROR_NOMEMORY if match_data and mcontext both are NULL
Subject: [pcre-dev] [Bug 2190] New: This will always return PCRE2_ERROR_NOMEMORY if match_data and mcontext both are NULL
https://bugs.exim.org/show_bug.cgi?id=2190

            Bug ID: 2190
           Summary: This will always return PCRE2_ERROR_NOMEMORY if
                    match_data and mcontext both are NULL
           Product: PCRE
           Version: 10.30 (PCRE2)
          Hardware: x86
                OS: All
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: ph10@???
          Reporter: mvelanka@???
                CC: pcre-dev@???


I see that the function pcre2_substitute has the following code

...
...
if (match_data == NULL)
  {
  pcre2_general_context *gcontext = (mcontext == NULL)?
    (pcre2_general_context *)code :
    (pcre2_general_context *)mcontext;
  match_data = pcre2_match_data_create_from_pattern(code, gcontext);
  if (match_data == NULL) return PCRE2_ERROR_NOMEMORY;
  match_data_created = TRUE;
}
...
...


So if I am not wrong, if match_data == NULL and mcontext is also NULL then
gcontext becomes equal to code ???
and then
match data is prepared with
match_data = pcre2_match_data_create_from_pattern(code, code) ????

this is bound to fail ........is it not?
Please see.

As I think, the line should have been
pcre2_general_context *gcontext = (mcontext == NULL)?
    (pcre2_general_context *)NULL:
    (pcre2_general_context *)mcontext;


Please note, I am relatively a newbie in this, so please excuse me if the above
does not make any sense.

Thanks

--
You are receiving this mail because:
You are on the CC list for the bug.