mirror of
https://github.com/pi-hole/FTL.git
synced 2025-12-20 04:48:24 +00:00
Merge pull request #2675 from pi-hole/fix/ftl_flua_crash
Fix pihole.format_path() memory handling
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user