Re: C++ std::string tries to free() a not allocated pointer ?
Re: C++ std::string tries to free() a not allocated pointer ?
- Subject: Re: C++ std::string tries to free() a not allocated pointer ?
- From: Jean-Denis Muys <email@hidden>
- Date: Thu, 19 Nov 2009 16:34:32 +0100
On Thursday, November 19, 2009, at 04:15PM, "Robert Schwalbe" <email@hidden> wrote:
>
>I would also contend that your assignment operators should protect
>against self assignment, e.g:
>
> const SQLString & operator=(const SQLString & rhs)
> {
> if (this != &rhs) {
> realStr = rhs.realStr;
> }
> return *this;
> }
>
Perhaps, though in that case, I think it would be harmless.
As I mentioned, I am not the author. This code is in mySQL connector-C++ library.
I just declare a local variable of type SQLString, that malloc complains about destructing when it leaves its lexical scope:
{
sql::SQLString temp = res->getString(colNum); // getString basically does "return sql::SQLString(p, 0);" where p points to a new char[23]
// use temp some
} // malloc complains destructing temp "pointer was not allocated"
JD
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden