public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "peturr02 at ru dot is" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/12540] New: Memory leak in locale::locale(const char*) Date: Wed, 08 Oct 2003 12:22:00 -0000 [thread overview] Message-ID: <20031008122204.12540.peturr02@ru.is> (raw) PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12540 Summary: Memory leak in locale::locale(const char*) Product: gcc Version: 3.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: peturr02 at ru dot is CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu There is a memory leak in the constructor locale::locale(const char*). The string allocated with strdup in the following snippet is leaked under some conditions. // LANG may set a default different from "C". char* __env = std::getenv("LANG"); if (!__env || std::strcmp(__env, "") == 0 || std::strcmp(__env, "C") == 0 || std::strcmp(__env, "POSIX") == 0) __res = strdup("C"); else __res = strdup(__env); [...] } __str.erase(__str.end() - 1); _M_impl = new _Impl(__str.c_str(), 1); } // ... otherwise either an additional instance of // the "C" locale or LANG. else if (std::strcmp(__res, "C") == 0) (_M_impl = _S_classic)->_M_add_reference(); else _M_impl = new _Impl(__res, 1); std::free(__res); The leak occurs if the calls to locale::_Impl::_Impl throws an exception, in that case free isn't called.
next reply other threads:[~2003-10-08 12:22 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-10-08 12:22 peturr02 at ru dot is [this message] 2003-10-08 12:25 ` [Bug libstdc++/12540] " peturr02 at ru dot is 2003-10-08 12:26 ` peturr02 at ru dot is 2003-10-08 13:08 ` paolo at gcc dot gnu dot org 2003-10-16 17:24 ` cvs-commit at gcc dot gnu dot org 2003-10-16 17:59 ` paolo at gcc dot gnu dot org 2003-10-17 18:20 ` pinskia at gcc dot gnu dot org 2004-01-29 2:35 ` pcarlini at suse dot de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20031008122204.12540.peturr02@ru.is \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).