Bug #803

Bad Clear() call to a const char *

Added by Iñaki Zabala about 7 years ago. Updated about 7 years ago.

Status:RejectedStart date:07/05/2014
Priority:NormalDue date:
Assignee:Iñaki Zabala% Done:

0%

Category:CoreSpent time:-
Target version:-

Description

In Socket.cpp, line 893, errordesc is a const char *, however errordesc.Clear() is called.

void TcpSocket::SetSockError(const char *context, int code, const char *errdesc) {
errorcode = code;
errordesc.Clear();

History

#1 Updated by Miroslav Fidler about 7 years ago

  • Status changed from New to In Progress
  • Assignee changed from Miroslav Fidler to Iñaki Zabala

I see "errdesc" being const char *. "errordesc" is String member of TcpSocket.

Have I got it wrong?

#2 Updated by Iñaki Zabala about 7 years ago

  • Assignee changed from Iñaki Zabala to Miroslav Fidler

Hello Mirek

However errordesc is also an argument in SetSockError. Please check the argument list:

void TcpSocket::SetSockError(const char context, int code, *const char *errdesc) {
errorcode = code;
errordesc.Clear();

#3 Updated by Miroslav Fidler about 7 years ago

  • Assignee changed from Miroslav Fidler to Iñaki Zabala

Please check carefully what is there. It is "errdesc", not "errordesc". Besides, it would compile, would it?

#4 Updated by Iñaki Zabala about 7 years ago

  • Status changed from In Progress to Rejected

Oups!

The problem came in errordesc.Clear();, but the reason was that my program indirectly deleted a TcpSocket used by an opened thread. Accidentally, the IsAbort() fired and the deleted TcpSocket went to SetSockError() where it finally exploded in the Clear() (as TcpSocket errordesc was previously deleted)...

Now I have changed the main class destructor so it cares of Abort() all TcpSocket, checks that all processes are ended and then, deletes itself.

Thank you.

Also available in: Atom PDF