Skip to content

Commit 77e6fcc

Browse files
committed
[AppSec] Free the WAF diagnostics of every config applied to the builder
ddwaf_builder_add_or_update_config allocates a fresh diagnostics object on every call and overwrites the one it is given without freeing it, so reusing a single object across the loop leaked all but the last one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Remove comments on WAF diagnostics object handling Removed comments about WAF diagnostics object allocation and reuse.
1 parent 57f3327 commit 77e6fcc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tracer/src/Datadog.Trace/AppSec/Waf/Initialization/WafConfigurator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,15 @@ internal UpdateResult Update(IntPtr wafBuilderHandle, ConfigurationState configu
251251
{
252252
var configObj = encoded.ResultDdwafObject;
253253
var path = config.Key;
254-
if (!_wafLibraryInvoker.BuilderAddOrUpdateConfig(wafBuilderHandle, path, ref configObj, ref diagnostics))
254+
255+
var configDiagnostics = default(DdwafObjectStruct);
256+
if (!_wafLibraryInvoker.BuilderAddOrUpdateConfig(wafBuilderHandle, path, ref configObj, ref configDiagnostics))
255257
{
256258
Log.Debug("WAF builder: Config failed to load : {0}", path); // Check were all these error codes are defined
257259
}
260+
261+
_wafLibraryInvoker.ObjectDestroy(ref diagnostics);
262+
diagnostics = configDiagnostics;
258263
}
259264
}
260265
}

0 commit comments

Comments
 (0)