From 6459b3ee29e13d5141b9e7b40bb4abce68c404be Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Aug 2006 13:46:51 +0000 Subject: Revert leaks from r4311, and also the leak fixes as a result of that utf8ToFsCharset() and fsCharsetToUtf8() got very broken in r4311, and resulted in several commits to fix those leaks. Unfortunately, not all of those newly introduced leaks were fixed, nor was the result pretty. Also, fixed a double-free in lsPlaylists(). This is very hard to trigger (and therefore exploit) at the moment because we check printDirectoryInfo() beforehand. Intended behavior for utf8ToFsCharset() and fsCharsetToUtf8() as God^H^H^Hshank originally intended is now documented in path.h to prevent future errors like this. mpd could still use some good valgrind testing before the 0.12.0 release. In addition to reducing heap fragmentation, malloc reductions from mpd-ke greatly reduces the chance of leaks from happening due to programming errors. git-svn-id: https://svn.musicpd.org/mpd/trunk@4639 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/path.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/path.h') diff --git a/src/path.h b/src/path.h index 222e145a5..e9fd36fa0 100644 --- a/src/path.h +++ b/src/path.h @@ -29,8 +29,17 @@ void initPaths(); void finishPaths(); +/* utf8ToFsCharset() and fsCharsetToUtf8() + * Each returns a static pointer to a dynamically allocated buffer + * which means: + * - Do not manually free the return value of these functions, it'll be + * automatically freed the next time it is called. + * - They are not reentrant, strdup the return value immediately if + * you expect to call one of these functions again, but still need the + * previous result. + * - The static pointer is unique to each function. + */ char *utf8ToFsCharset(char *str); - char *fsCharsetToUtf8(char *str); void setFsCharset(char *charset); -- cgit v1.2.3