[llvm-commits] [llvm] r166517 - /llvm/trunk/include/llvm/ADT/StringSet.h
Sean Silva
silvas at purdue.edu
Thu Oct 25 11:27:40 PDT 2012
How did you find this?
-- Sean Silva
On Tue, Oct 23, 2012 at 6:55 PM, Michael J. Spencer
<bigcheesegs at gmail.com> wrote:
> Author: mspencer
> Date: Tue Oct 23 17:55:54 2012
> New Revision: 166517
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166517&view=rev
> Log:
> [Support/StringSet] Fix memory leak when inserted key already exists.
>
> Modified:
> llvm/trunk/include/llvm/ADT/StringSet.h
>
> Modified: llvm/trunk/include/llvm/ADT/StringSet.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringSet.h?rev=166517&r1=166516&r2=166517&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/StringSet.h (original)
> +++ llvm/trunk/include/llvm/ADT/StringSet.h Tue Oct 23 17:55:54 2012
> @@ -29,8 +29,13 @@
> assert(!InLang.empty());
> const char *KeyStart = InLang.data();
> const char *KeyEnd = KeyStart + InLang.size();
> - return base::insert(llvm::StringMapEntry<char>::
> - Create(KeyStart, KeyEnd, base::getAllocator(), '+'));
> + llvm::StringMapEntry<char> *Entry = llvm::StringMapEntry<char>::
> + Create(KeyStart, KeyEnd, base::getAllocator(), '+');
> + if (!base::insert(Entry)) {
> + Entry->Destroy(base::getAllocator());
> + return false;
> + }
> + return true;
> }
> };
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list