[swift-users] Swift 2.0: JID & StringPrep::getPrepared

Travis Loyd fun.tloyd at gmail.com
Wed Dec 16 16:44:20 UTC 2015


I know everything is moving on to 3.0, but I have what I hope is a quick
question with a quick answer related to the 2.0 library.

I've got some code that generates a tiny memory leak if I add a resource to
a JID.

std::string key;
std::string bucket =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

// test for leak
JID *tmpJID;
for (int ctr = 0; ctr < 100; ctr ++) {
raw = "harmony\\travis at 127.0.0.1";
key = "";
for (int i = 0; i < 15; i++) {
key += bucket[rand() % bucket.length()];
}
raw.append("/");
raw.append(key);

tmpJID = new JID(raw);
delete tmpJID;
}

When I perform a memory dump I can see a left over 'resource' portion from
the JID after everything should have been cleaned up.

Detected memory leaks!
Dumping objects ->
{3598} normal block at 0x03094C48, 60 bytes long.
 Data: < H  T23ykQ0zpp7Y> 88 48 09 03 54 32 33 79 6B 51 30 7A 70 70 37 59
{3588} normal block at 0x03094BD0, 60 bytes long.
 Data: < :  ZylsMEQYJ5qu> F8 3A 09 03 5A 79 6C 73 4D 45 51 59 4A 35 71 75
{3578} normal block at 0x03094B58, 60 bytes long.
 Data: <    C7l7Ptvz2T9N> 00 00 00 00 43 37 6C 37 50 74 76 7A 32 54 39 4E
... snip ...

I'm looking for a fix.  Am I using something incorrectly?  Or, have I found
a bug?  (Maybe related to StringPrep?)  Is there a more updated 2.0 library
out there which I'm unaware of?  I've got the latest AFAIK.  Environment is
Windows 7, Visual Studio 2010 & openssl.

Thank you for an amazing library!


Travis Loyd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </lists/pipermail/swift-users/attachments/20151216/83cd401e/attachment.html>


More information about the swift-users mailing list