CP-Templates icon indicating copy to clipboard operation
CP-Templates copied to clipboard

Potential memory leak for Trie template

Open DotRacel opened this issue 6 months ago • 0 comments

using g++ (GCC) 14.1.1 20240720 with compiler argument -fsanitize=address Address Sanitizer will report the memory leaks.

~Trie() {
   deleteNode(root);
}

void deleteNode(Node* node) {
   if (!node) return;
   for (int i = 0; i < charSize(); ++i) {
       deleteNode(node->children[i]);
   }
   delete node;
}

fixes the leak.

DotRacel avatar Aug 12 '24 02:08 DotRacel