mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Ensure usage of __attribute__(cleanup) never frees un-initialized memory
Use macros that take an initializer parameter to, thereby ensuring the variable to be cleaned up is always initialized.
This commit is contained in:
@@ -192,18 +192,18 @@ text_composition_strategy(PyObject *val, Options *opts) {
|
||||
else if (PyUnicode_CompareWithASCIIString(val, "legacy") == 0) {
|
||||
opts->text_old_gamma = true;
|
||||
} else {
|
||||
DECREF_AFTER_FUNCTION PyObject *parts = PyUnicode_Split(val, NULL, 2);
|
||||
RAII_PyObject(parts, PyUnicode_Split(val, NULL, 2));
|
||||
int size = PyList_GET_SIZE(parts);
|
||||
if (size < 1 || 2 < size) { PyErr_SetString(PyExc_ValueError, "text_rendering_strategy must be of the form number:[number]"); return; }
|
||||
|
||||
if (size > 0) {
|
||||
DECREF_AFTER_FUNCTION PyObject *ga = PyFloat_FromString(PyList_GET_ITEM(parts, 0));
|
||||
RAII_PyObject(ga, PyFloat_FromString(PyList_GET_ITEM(parts, 0)));
|
||||
if (PyErr_Occurred()) return;
|
||||
opts->text_gamma_adjustment = MAX(0.01f, PyFloat_AsFloat(ga));
|
||||
}
|
||||
|
||||
if (size > 1) {
|
||||
DECREF_AFTER_FUNCTION PyObject *contrast = PyFloat_FromString(PyList_GET_ITEM(parts, 1));
|
||||
RAII_PyObject(contrast, PyFloat_FromString(PyList_GET_ITEM(parts, 1)));
|
||||
if (PyErr_Occurred()) return;
|
||||
opts->text_contrast = MAX(0.0f, PyFloat_AsFloat(contrast));
|
||||
opts->text_contrast = MIN(100.0f, opts->text_contrast);
|
||||
|
||||
Reference in New Issue
Block a user