Merge pull request #2675 from pi-hole/fix/ftl_flua_crash

Fix pihole.format_path() memory handling
This commit is contained in:
Adam Warner
2025-10-28 13:35:29 +00:00
committed by GitHub

View File

@@ -279,6 +279,7 @@ static int pihole_format_path(lua_State *L) {
} }
// Strip leading webhome from page_copy (if it exists) // Strip leading webhome from page_copy (if it exists)
char *page_copy_start = page_copy;
if (config.webserver.paths.webhome.v.s != NULL) if (config.webserver.paths.webhome.v.s != NULL)
{ {
const size_t webhome_len = strlen(config.webserver.paths.webhome.v.s); const size_t webhome_len = strlen(config.webserver.paths.webhome.v.s);
@@ -302,8 +303,8 @@ static int pihole_format_path(lua_State *L) {
lua_pushstring(L, page_copy); lua_pushstring(L, page_copy);
} }
// Free allocated memory // Free originally allocated memory (page_copy may have been modified)
free(page_copy); free(page_copy_start);
return 1; // number of results return 1; // number of results
} }