• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++ std::string tries to free() a not allocated pointer ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ std::string tries to free() a not allocated pointer ?


  • Subject: Re: C++ std::string tries to free() a not allocated pointer ?
  • From: Robert Schwalbe <email@hidden>
  • Date: Wed, 18 Nov 2009 14:05:23 -0500

class SQLString
{
	std::string realStr;
public:
	~SQLString() {}
	SQLString(const char * s, size_t n) : realStr(s, n) {}
};

[other public member functions irrelevant because not called.]

3- a buffer is allocated with 23 bytes in the library, form which a SQLString is constructed.
The calling sequence I stepped through in the library is:


buffer = new char[23];
buffer[0] = 0;
length = 0;
return SQLString(buffer, length);

4- that return statement constructs a temporary SQLString through that call chain:

Try providing a copy constructor for your SQLString class.

I believe without the presence of a copy constructor a blockmove/memcopy
is performed and that will not copy the realStr member as it should.
_______________________________________________
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


References: 
 >C++ std::string tries to free() a not allocated pointer ? (From: Jean-Denis Muys <email@hidden>)

  • Prev by Date: Re: C++ std::string tries to free() a not allocated pointer ?
  • Next by Date: dsymutil vs current FSF gcc VTA merge
  • Previous by thread: Re: C++ std::string tries to free() a not allocated pointer ?
  • Next by thread: Re: C++ std::string tries to free() a not allocated pointer ?
  • Index(es):
    • Date
    • Thread