components/net-snmp/patches/040.17812413.logmatch_free.patch
changeset 1776 614fab3c797e
equal deleted inserted replaced
1775:221ebe7e8513 1776:614fab3c797e
       
     1 # This patch has been submitted upstream. But it has not been accepted yet.
       
     2 
       
     3 --- a/agent/mibgroup/ucd-snmp/logmatch.c	Thu Sep 14 17:48:50 2006
       
     4 +++ b/agent/mibgroup/ucd-snmp/logmatch.c	Wed Feb  5 23:56:38 2014
       
     5 @@ -118,8 +118,8 @@
       
     6       */
       
     7  
       
     8      for (i = 0; i < logmatchCount; i++) {
       
     9 -
       
    10 -        regfree(&(logmatchTable[i].regexBuffer));
       
    11 +        if (logmatchTable[i].myRegexError == 0)
       
    12 +            regfree(&(logmatchTable[i].regexBuffer));
       
    13      }
       
    14      logmatchCount = 0;
       
    15  }
       
    16 @@ -212,6 +212,17 @@
       
    17              regcomp(&(logmatchTable[logmatchCount].regexBuffer),
       
    18                      logmatchTable[logmatchCount].regEx,
       
    19                      REG_EXTENDED | REG_NOSUB);
       
    20 +		if (logmatchTable[logmatchCount].myRegexError)
       
    21 +		{
       
    22 +			char regexErrorString[100];
       
    23 +			regerror(logmatchTable[logmatchCount].myRegexError,
       
    24 +					&(logmatchTable[logmatchCount].regexBuffer),
       
    25 +					regexErrorString, 100);
       
    26 +			regexErrorString[99] = '\0';
       
    27 +			snmp_log(LOG_ERR, "Could not process the logmatch regex - %s," \
       
    28 +					"\n since regcomp() failed with - %s\n",
       
    29 +					logmatchTable[logmatchCount].regEx, regexErrorString);
       
    30 +		}
       
    31  
       
    32          if (logmatchTable[logmatchCount].frequency > 0) {
       
    33              snmp_alarm_register(logmatchTable[logmatchCount].frequency,