mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Fix bad new/delete usage
This commit is contained in:
parent
f11eb219ad
commit
8dae420bc8
10
src/x11.cc
10
src/x11.cc
@ -246,7 +246,7 @@ static int x11_error_handler(Display *d, XErrorEvent *err) {
|
|||||||
xcb_errors_ctx, err->error_code, &extension);
|
xcb_errors_ctx, err->error_code, &extension);
|
||||||
if (extension != nullptr) {
|
if (extension != nullptr) {
|
||||||
const std::size_t size = strlen(base_name) + strlen(extension) + 4;
|
const std::size_t size = strlen(base_name) + strlen(extension) + 4;
|
||||||
error_name = new char(size);
|
error_name = new char[size];
|
||||||
snprintf(error_name, size, "%s (%s)", base_name, extension);
|
snprintf(error_name, size, "%s (%s)", base_name, extension);
|
||||||
name_allocated = true;
|
name_allocated = true;
|
||||||
} else {
|
} else {
|
||||||
@ -259,7 +259,7 @@ static int x11_error_handler(Display *d, XErrorEvent *err) {
|
|||||||
xcb_errors_ctx, err->request_code, err->minor_code);
|
xcb_errors_ctx, err->request_code, err->minor_code);
|
||||||
if (minor != nullptr) {
|
if (minor != nullptr) {
|
||||||
const std::size_t size = strlen(base_name) + strlen(extension) + 4;
|
const std::size_t size = strlen(base_name) + strlen(extension) + 4;
|
||||||
code_description = new char(size);
|
code_description = new char[size];
|
||||||
snprintf(code_description, size, "%s - %s", major, minor);
|
snprintf(code_description, size, "%s - %s", major, minor);
|
||||||
code_allocated = true;
|
code_allocated = true;
|
||||||
} else {
|
} else {
|
||||||
@ -284,7 +284,7 @@ static int x11_error_handler(Display *d, XErrorEvent *err) {
|
|||||||
}
|
}
|
||||||
if (code_description == nullptr) {
|
if (code_description == nullptr) {
|
||||||
const std::size_t size = 37;
|
const std::size_t size = 37;
|
||||||
code_description = new char(size);
|
code_description = new char[size];
|
||||||
snprintf(code_description, size, "error code: [major: %i, minor: %i]",
|
snprintf(code_description, size, "error code: [major: %i, minor: %i]",
|
||||||
err->request_code, err->minor_code);
|
err->request_code, err->minor_code);
|
||||||
code_allocated = true;
|
code_allocated = true;
|
||||||
@ -297,8 +297,8 @@ static int x11_error_handler(Display *d, XErrorEvent *err) {
|
|||||||
error_name, reinterpret_cast<uint64_t>(err->display),
|
error_name, reinterpret_cast<uint64_t>(err->display),
|
||||||
static_cast<int64_t>(err->resourceid), err->serial, code_description);
|
static_cast<int64_t>(err->resourceid), err->serial, code_description);
|
||||||
|
|
||||||
if (name_allocated) free(error_name);
|
if (name_allocated) delete[] error_name;
|
||||||
if (code_allocated) free(code_description);
|
if (code_allocated) delete[] code_description;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user