fix: double free WebDAVHandler (#1093)

## Summary

Ref:
https://github.com/crosspoint-reader/crosspoint-reader/pull/1047#discussion_r2838439305

To reproduce:
1. Open file transfer
2. Join a network
3. Once it's connected, press (hold) back

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? **NO**
This commit is contained in:
Xuan-Son Nguyen
2026-02-22 22:20:41 +01:00
committed by GitHub
parent 4ccafe5cfa
commit 75ff7b25ab
2 changed files with 2 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
#include "CrossPointSettings.h"
#include "SettingsList.h"
#include "WebDAVHandler.h"
#include "html/FilesPageHtml.generated.h"
#include "html/HomePageHtml.generated.h"
#include "html/SettingsPageHtml.generated.h"
@@ -162,7 +163,7 @@ void CrossPointWebServer::begin() {
// Collect WebDAV headers and register handler
const char* davHeaders[] = {"Depth", "Destination", "Overwrite", "If", "Lock-Token", "Timeout"};
server->collectHeaders(davHeaders, 6);
server->addHandler(&davHandler);
server->addHandler(new WebDAVHandler()); // Note: WebDAVHandler will be deleted by WebServer when server is stopped
LOG_DBG("WEB", "WebDAV handler initialized");
server->begin();

View File

@@ -9,8 +9,6 @@
#include <string>
#include <vector>
#include "WebDAVHandler.h"
// Structure to hold file information
struct FileInfo {
String name;
@@ -73,7 +71,6 @@ class CrossPointWebServer {
private:
std::unique_ptr<WebServer> server = nullptr;
std::unique_ptr<WebSocketsServer> wsServer = nullptr;
WebDAVHandler davHandler;
bool running = false;
bool apMode = false; // true when running in AP mode, false for STA mode
uint16_t port = 80;