[zeromq-dev] [PATCH] Fix Windows memory leak
Тарас Шпот
mrshpot at gmail.com
Fri Oct 15 16:39:07 CEST 2010
Hello.
Here is a fix for a bug discovered by Pavlo Mosorin, submitted by me.
>From 6c654c2a46761252cbb9ccfc0c32839aba458402 Mon Sep 17 00:00:00 2001
From: Taras Shpot <taras.shpot at eleks.com>
Date: Fri, 15 Oct 2010 17:34:40 +0300
Subject: [PATCH] Fix memory leak under Windows
The comment about memory ownership in uuid_t::to_string
was misleading as on most platforms the buffer is a field
of the object;
The string allocated in UuidToString() wasn't properly freed
with RpcStringFree()
Signed-off-by: Taras Shpot <taras.shpot at eleks.com>
---
src/uuid.cpp | 2 ++
src/uuid.hpp | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/uuid.cpp b/src/uuid.cpp
index f1dddf0..652ef22 100644
--- a/src/uuid.cpp
+++ b/src/uuid.cpp
@@ -41,6 +41,8 @@ zmq::uuid_t::uuid_t ()
zmq::uuid_t::~uuid_t ()
{
+ if (string_buf)
+ RpcStringFree (&string_buf);
}
const char *zmq::uuid_t::to_string ()
diff --git a/src/uuid.hpp b/src/uuid.hpp
index 871f827..a528baf 100644
--- a/src/uuid.hpp
+++ b/src/uuid.hpp
@@ -58,7 +58,7 @@ namespace zmq
enum { uuid_string_len = 36 };
// Returns a pointer to buffer containing the textual
- // representation of the UUID. The caller is reponsible to
+ // representation of the UUID. The callee is reponsible to
// free the allocated memory.
const char *to_string ();
--
1.7.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101015/478ce57d/attachment.htm>
More information about the zeromq-dev
mailing list