add proper clean up when quit the func (as per Raster comment)
Diff Detail
- Repository
- rEFL core/efl
- Branch
- arcpatch-D4175
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 2382 Build 2447: arc lint + arc unit
In theory this can be true in out of memory case:
There is an engine, then strdup(engine) and it may return NULL
src/lib/ecore_evas/ecore_evas_ews.c | ||
---|---|---|
1326 | You missed to reset the pointer you free (_ews_engine), to null. But you shouldn't worry with the free, this global will be released when the program finishes. Maybe just force _ews_defaults_engine = EINA_TRUE. actually this can be done before the 2 "if" |
yeah this code isn't totally dead. if strdup fails... but on failure it will possibly leak tho and not clean up nicely.
it should more be line:
_ews_engine = engine ? strdup(engine) : NULL; _ews_options = options ? strdup(options) : NULL; if ((engine) && (!_ews_engine)) return EINA_FALSE; if ((options) && (!_ews_options)) { free(_ews_engine); _ews_engine = NULL; return EINA_FALSE; }
Raster, while your approach is correct, these variables are cleared on shutdown (no leaks) and they are only used by the core if _ews_defaults_engine == EINA_FALSE, which is set after these checks.
then, to make it really safe, after you free the pointers, please enforce _ews_defaults_engine = EINA_TRUE.
_ews_engine = engine ? strdup(engine) : NULL; _ews_options = options ? strdup(options) : NULL; if ((engine) && (!_ews_engine)) return EINA_FALSE; if ((options) && (!_ews_options)) { free(_ews_engine); _ews_engine = NULL; _ews_defaults_engine = EINA_TRUE; return EINA_FALSE; }