Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#17679 closed defect (fixed)

wxFTP::PWD() error

Reported by: o.kolomiytsev Owned by: vadz
Priority: normal Milestone:
Component: wxMSW Version: 3.1.0
Keywords: wxFTP Cc:
Blocked By: Blocking:
Patch: yes

Description

Hi,
Looks like i have found error during using wxFTP::PWD();

My code is:

wxFTP ftp;
ftp.SetUser(wxT("username"));
ftp.SetPassword(wxT("password"));

if (ftp.Connect("ip_address"))
{

std::cout << "Connected" << std::endl;
wxString str = ftp.Pwd(); <<------- ERROR: string iterator not dereferencable

}

Program crashes when i am going to use Pwd() function.

Attachments (5)

error.png download (82.9 KB) - added by o.kolomiytsev 3 years ago.
Assert error
ppointer.png download (30.7 KB) - added by o.kolomiytsev 3 years ago.
After this step program is going to crash.
wxFTP_error.7z download (1.3 KB) - added by o.kolomiytsev 3 years ago.
Minimum sample to reproduce error
crash.png download (29.9 KB) - added by o.kolomiytsev 3 years ago.
I don't know, but code crashes at this point.
wxftp.patch download (957 bytes) - added by o.kolomiytsev 3 years ago.
In this patch I have modified minimal sample and have added code that crashes application with wxFTP::Pwd()

Download all attachments as: .zip

Change History (14)

Changed 3 years ago by o.kolomiytsev

Assert error

Changed 3 years ago by o.kolomiytsev

After this step program is going to crash.

comment:1 follow-up: Changed 3 years ago by vadz

Please provide the smallest possible self-contained example reproducing the problem or a patch to the minimal sample (found under samples/minimal in wxWidgets source tree) adding the code reproducing it. This would make it much simpler for us to debug the problem and test the fix. Thanks in advance!

Changed 3 years ago by o.kolomiytsev

Minimum sample to reproduce error

comment:2 Changed 3 years ago by o.kolomiytsev

Problematic code in constructor of NullFrame class.

comment:3 in reply to: ↑ 1 Changed 3 years ago by neis

Replying to vadz:

Please provide the smallest possible self-contained example reproducing the problem

Without trying to verify in the sample, but shouldn't that read p == m_lastResult.end() instead of !*p in wxFTP:Pwd() (two places in that function)?

Changed 3 years ago by o.kolomiytsev

I don't know, but code crashes at this point.

comment:4 Changed 3 years ago by vadz

Sorry, I don't even seem to be able to decompress your archive. Could you please read the instructions in HowToSubmitPatches?

comment:5 Changed 3 years ago by o.kolomiytsev

Ok, i will give you patch a bit later.

Last edited 3 years ago by o.kolomiytsev (previous) (diff)

comment:6 Changed 3 years ago by o.kolomiytsev

  • Patch set

Changed 3 years ago by o.kolomiytsev

In this patch I have modified minimal sample and have added code that crashes application with wxFTP::Pwd()

comment:7 Changed 3 years ago by vadz

  • Owner set to vadz
  • Status changed from new to accepted

Great, thanks for the patch, I'll have a look at it soon.

comment:8 Changed 3 years ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In d0c57dbef0937f59280804b3fcfaf1658605b7ca/git-wxWidgets:

Fix string iteration logic in wxFTP::Pwd()

wxString iterators can't be dereferenced once they reach the end of the
string, so compare them with end rather than checking if the value they point
to is non-NUL.

This makes wxFTP::Pwd() actually work, which was apparently broken since quite
some time (perhaps ever since c9f7896861f734ce044ee8601ba2d8a6959c9d9e 9+
years ago).

Closes #17679.

comment:9 Changed 3 years ago by Vadim Zeitlin <vadim@…>

In d77661c73bf6f9668077ac5a85b4854a1a2204ee/git-wxWidgets:

Fix string iteration logic in wxFTP::Pwd()

wxString iterators can't be dereferenced once they reach the end of the
string, so compare them with end rather than checking if the value they point
to is non-NUL.

This makes wxFTP::Pwd() actually work, which was apparently broken since quite
some time (perhaps ever since c9f7896861f734ce044ee8601ba2d8a6959c9d9e 9+
years ago).

See #17679.

(cherry picked from commit d0c57dbef0937f59280804b3fcfaf1658605b7ca)

Note: See TracTickets for help on using tickets.