Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334658 - Mismatching de-allocation operator in gdip_custom.cpp
Summary: Mismatching de-allocation operator in gdip_custom.cpp
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-18 10:27 EST by Niels Thykier CLA
Modified: 2011-01-25 16:37 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niels Thykier CLA 2011-01-18 10:27:37 EST
Build Identifier: 

Hi

cppcheck (1.44) reports the following against org.eclipse.swt/Eclipse SWT PI/win32/library/gdip_custom.cpp

[gdip_custom.cpp:39]: (error) Mismatching allocation and deallocation: points
[gdip_custom.cpp:65]: (error) Mismatching allocation and deallocation: points
[gdip_custom.cpp:91]: (error) Mismatching allocation and deallocation: points
[gdip_custom.cpp:117]: (error) Mismatching allocation and deallocation: points
[gdip_custom.cpp:182]: (error) Mismatching allocation and deallocation: colors
[gdip_custom.cpp:211]: (error) Mismatching allocation and deallocation: colors
[gdip_custom.cpp:240]: (error) Mismatching allocation and deallocation: colors
[gdip_custom.cpp:271]: (error) Mismatching allocation and deallocation: points
[gdip_custom.cpp:342]: (error) Mismatching allocation and deallocation: points

I checked a few of them and it is triggered by code like:

...
	Color *colors=NULL;
...
		colors = new Color[arg3];
....
	if (lparg1 && colors) {
		delete colors;
	}
...

I believe the correction would be to use delete[] in this particular case.  Note I did not manually verify all of them.

~Niels



Reproducible: Always
Comment 1 Felipe Heidrich CLA 2011-01-18 12:01:38 EST
Fixed in HEAD
Thank you.

Intersting, the file (gdip_custom.cpp) had other instances of delete array that the tool didn't find.