Skip to content

Commit 448402c

Browse files
committed
[Diagnostics] Free memory associated with printed string
1 parent 13c849c commit 448402c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/ASTGen/Sources/ASTGen/Diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ public func addQueuedDiagnostic(
445445

446446
/// Render the queued diagnostics into a UTF-8 string.
447447
@_cdecl("swift_ASTGen_renderQueuedDiagnostics")
448-
public func renterQueuedDiagnostics(
448+
public func renderQueuedDiagnostics(
449449
queuedDiagnosticsPtr: UnsafeMutablePointer<UInt8>,
450450
contextSize: Int,
451451
colorize: Int,

lib/Frontend/PrintingDiagnosticConsumer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern "C" void swift_ASTGen_addQueuedDiagnostic(
5454
extern "C" void swift_ASTGen_renderQueuedDiagnostics(
5555
void *queued, ptrdiff_t contextSize, ptrdiff_t colorize,
5656
char **outBuffer, ptrdiff_t *outBufferLength);
57+
extern "C" void swift_ASTGen_freeString(const char *str);
5758

5859
// FIXME: Hack because we cannot easily get to the already-parsed source
5960
// file from here. Fix this egregious oversight!
@@ -1201,6 +1202,7 @@ void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) {
12011202
&renderedString, &renderedStringLen);
12021203
if (renderedString) {
12031204
Stream.write(renderedString, renderedStringLen);
1205+
swift_ASTGen_freeString(renderedString);
12041206
}
12051207
swift_ASTGen_destroyQueuedDiagnostics(queuedDiagnostics);
12061208
queuedDiagnostics = nullptr;

0 commit comments

Comments
 (0)