Skip to content

Commit 11cf4db

Browse files
authored
Merge pull request #3701 from smoe/libnml_config_mem_leak
libnml: Fixed memleak in configuration parsing
2 parents 93643c1 + 63ab861 commit 11cf4db

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/emc/usr_intf/axis/extensions/emcmodule.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,10 @@ static PyObject *pydraw_lines(PyObject * /*s*/, PyObject *o) {
20542054
if(!first) glEnd();
20552055
return NULL;
20562056
}
2057+
2058+
// Suppress cppcheck false positive:
2059+
// 'first' == 1 when 'pl' is undefined and therefore not a problem.
2060+
// cppcheck-suppress uninitvar
20572061
if(first || memcmp(p1, pl, sizeof(p1))
20582062
|| (for_selection && n != nl)) {
20592063
if(!first) glEnd();

src/libnml/cms/cms_cfg.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ int load_nml_config_file(const char *file)
114114
if (strlen(file) >= 80) {
115115
rcs_print_error("cms_config: file name too long\n");
116116
loading_config_file = 0;
117+
delete info->lines_list; // info is a struct
118+
delete info;
117119
return -1;
118120
}
119121
rtapi_strlcpy(info->file_name, file, 80);
@@ -122,6 +124,7 @@ int load_nml_config_file(const char *file)
122124
if (fp == NULL) {
123125
rcs_print_error("cms_config: can't open '%s'. Error = %d -- %s\n",
124126
file, errno, strerror(errno));
127+
delete info->lines_list; // info is a struct
125128
delete info;
126129
loading_config_file = 0;
127130
return -1;

0 commit comments

Comments
 (0)