Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334658

Summary: Mismatching de-allocation operator in gdip_custom.cpp
Product: [Eclipse Project] Platform Reporter: Niels Thykier <niels>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe
Version: 4.1   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows All   
Whiteboard:

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.