\build-aux\speedo\w32\g4wihelp.c line 1162
missing
free (path_new);
\build-aux\speedo\w32\g4wihelp.c line 1162
missing
free (path_new);
rG GnuPG | |||
rG13dc75a4e7cc speedo: Fix a minor memleak in the installer |
I don't see the bug. Please elaborate. path_new is is freed in line 1065 but if this condition does not match it's freed in line 1079.
Please reopen if you can elaborate under which condition memory is leaked there.
void __declspec(dllexport) path_remove (HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters_t *extra) { char dir[PATH_LENGTH_LIMIT]; char is_user_install[2]; char *path; char *path_new; int path_new_size; char *comp; const char delims[] = ";"; HKEY key_handle = 0; int changed = 0; int count = 0; HKEY root_key; const char *env_reg; g_hwndParent = hwndParent; EXDLL_INIT(); setuservariable (INST_R0, "0"); /* The expected stack layout: path component. */ if (popstring (dir, sizeof (dir))) return; /* The expected stack layout: HKEY component. */ if (popstring (is_user_install, sizeof (is_user_install))) return; if (!strcmp(is_user_install, "1")) { root_key = ENV_HK_USER; env_reg = ENV_REG_USER; } else { root_key = ENV_HK; env_reg = ENV_REG; } path = read_w32_registry_string (root_key, env_reg, "Path"); if (!path) return; /* Old path plus semicolon plus dir plus terminating nul. */ path_new_size = strlen (path) + 1; path_new = malloc (path_new_size); // allcoation if (!path_new) { free (path); return; } path_new[0] = '\0'; /* Compose the new path. */ comp = strtok (path, delims); do { if (strcmp (comp, dir)) { if (count != 0) strcat (path_new, ";"); strcat (path_new, comp); count++; } else changed = 1; comp = strtok (NULL, delims); } while (comp); free (path); if (! changed) return; // !!! no deallocation /* Set a key for our CLSID. */ RegCreateKey (root_key, env_reg, &key_handle); RegSetValueEx (key_handle, "Path", 0, REG_EXPAND_SZ, path_new, path_new_size); RegCloseKey (key_handle); free (path_new); setuservariable (INST_R0, "1"); }
Sorry. I looked at path_add and not at path_remove, see my garbled line numbers I started at 1062 and not 1162.
Ok. fixed with 13dc75a4e7cc2959003c08940fc53c6ece7b77e4 Thanks for the report. Please consider in the future to just send a patch. This would have been more clear then just adding a comment in the existing source.
thanks for help - could have been my mistake as well, so better look twice.
I prefer in that way because you have four eyes principle and as well one of the more experienced developers can review the source.
:-)