diff --git a/CHANGES b/CHANGES index bfc7e96f..87d340ee 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ SVN-HEAD Detect excessive recursion depth during expression eval (#2365) Return a string rather than NULL for unknown errors Skip non-file sysfs entries for speed + Fix memory leak in scanner when using flex 2.5.9 or later lm_sensors.init: Support new format of /etc/sysconfig/lm_sensors (#2246) Drop support for kernels 2.4 and earlier lm_sensors.init.suse: Delete (actual SuSE script is much different) diff --git a/lib/conf-lex.l b/lib/conf-lex.l index afacefa7..0268f693 100644 --- a/lib/conf-lex.l +++ b/lib/conf-lex.l @@ -350,5 +350,15 @@ void sensors_scanner_exit(void) { sensors_yy_delete_buffer(scan_buf); scan_buf = (YY_BUFFER_STATE)0; + +/* As of flex 2.5.9, yylex_destroy() must be called when done with the + scaller, otherwise we'll leak memory. */ +#if defined(YY_FLEX_MAJOR_VERSION) && defined(YY_FLEX_MINOR_VERSION) && defined(YY_FLEX_SUBMINOR_VERSION) +#if YY_FLEX_MAJOR_VERSION > 2 || \ + (YY_FLEX_MAJOR_VERSION == 2 && (YY_FLEX_MINOR_VERSION > 5 || \ + (YY_FLEX_MINOR_VERSION == 5 && YY_FLEX_SUBMINOR_VERSION >= 9))) + sensors_yylex_destroy(); +#endif +#endif }