kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #09965
Patch: Mismatch in new [] and delete in common/hotkeys_basic.cpp
Hello everyone,
Adam Wolf and I ran cppcheck against the kicad codebase, and it came back
with 27 results, but only 1 seemed valid from a first glance:
In the file common/hotkeys_basic.cpp, line 557 does the following memory
allocation:
char* buffer = new char[size];
At the end of the function, line 566 then cleans up that buffer:
delete buffer;
but it should actually be the array form of delete:
delete[] buffer;
Here is a tiny patch to fix this small issue:
=== modified file 'common/hotkeys_basic.cpp'
--- common/hotkeys_basic.cpp 2012-04-09 09:16:47 +0000
+++ common/hotkeys_basic.cpp 2013-04-13 22:53:57 +0000
@@ -563,7 +563,7 @@
ParseHotkeyConfig( data, aDescList );
/* cleanup */
- delete buffer;
+ delete[] buffer;
cfgfile.Close();
return 1;
}
It's also attached as a file, in case that is easier to work with.
Thanks much,
Matthew Beckler
Wayne and Layne, LLC
Attachment:
wnl_hotkeys_basic_delete_array.patch
Description: Binary data
Follow ups