Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect delete in Dispatch JNI invokev() #40

Closed
EJP286CRSKW opened this issue Sep 14, 2023 · 3 comments
Closed

Incorrect delete in Dispatch JNI invokev() #40

EJP286CRSKW opened this issue Sep 14, 2023 · 3 comments

Comments

@EJP286CRSKW
Copy link

EJP286CRSKW commented Sep 14, 2023

In the error handling case at the end of the method we have:

buf = CreateErrorMsgFromInfo(hr, &excepInfo, nm);

and

dispIdAsName = new char[256];

and later:

if (buf) delete buf;
if (dispIdAsName) delete dispIdAsName;

The latter should be:

delete[] buf;
delete[] dispIdAsName;

to agree with how they were created, as new wchar_t[...] and new char[...] respectively.
The null tests are unnecessary.

@EJP286CRSKW
Copy link
Author

Actually dispIdAsName could be declared as char dispIdAsName[256]; to avoid the delete [] altogether.

@EJP286CRSKW
Copy link
Author

For clarity, the problems here are:

  1. delete should be delete[] in both cases.
  2. The null tests are redundant in both cases.

@freemansoft
Copy link
Owner

8e4472e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants