Hi,
Regarding the third issue in file
regcomp.c, I saw that someone changed the code to avoid the possible memory leak in:
Commit id: e888f1834b88270590b7e04d64c03c75863e4565
01. sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
02. #ifdef RE_ENABLE_I18N
03. mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
04. #endif /* RE_ENABLE_I18N */
05. #ifdef RE_ENABLE_I18N
06. if (BE (sbcset == NULL || mbcset == NULL, 0))
07. #else
08. if (BE (sbcset == NULL, 0))
09. #endif /* RE_ENABLE_I18N */
10. {
11. re_free (sbcset);
12. #ifdef RE_ENABLE_I18N
13. re_free (mbcset);
14. #endif
15. *err = REG_ESPACE;
16. return NULL;
17. }
The developer adds lines 11, 12, 13, and 14. Okay, these lines avoid the memory leak in variables
mbcset and
sbcset. However, there is no reason to add line 11 outside the #ifdef code. When macro RE_ENABLE_I18N is not active,
sbcset is always
NULL.
In my opinion, the best solution would be:
10. {
11. #ifdef RE_ENABLE_I18N
12. re_free (sbcset);
13. re_free (mbcset);
14. #endif
15. *err = REG_ESPACE;
16. return NULL;
17. }
Regards,
Flávio Medeiros