From b0703b92c32d6802c88f00c62274ee5a372eaf1f Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Thu, 3 Aug 2017 00:25:30 +0200
Subject: [PATCH] util/FormatString: pass the allocated buffer to
 AllocatedString::Donate()

.. and not the stack buffer.  This made the AllocatedString destructor
crash.

Closes #52
---
 NEWS                      | 1 +
 src/util/FormatString.cxx | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 870287815..2b8dceb5b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.20.10 (not yet released)
   - ffmpeg: support MusicBrainz ID3v2 tags
 * tags
   - aiff: fix FORM chunk size endianess (is big-endian)
+* fix crash on Windows
 
 ver 0.20.9 (2017/06/04)
 * decoder
diff --git a/src/util/FormatString.cxx b/src/util/FormatString.cxx
index 00a208371..b5ea4d093 100644
--- a/src/util/FormatString.cxx
+++ b/src/util/FormatString.cxx
@@ -57,7 +57,7 @@ FormatStringV(const char *fmt, va_list args)
 	const size_t length = strlen(buffer);
 	char *p = new char[length + 1];
 	memcpy(p, buffer, length + 1);
-	return AllocatedString<>::Donate(buffer);
+	return AllocatedString<>::Donate(p);
 #endif
 }