From 6a098049107f93824fe947ca7c96c1d6ea0f5a48 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Nov 2023 19:34:35 +0530 Subject: [PATCH] Fix loading of window logo images via @launch Use the path when either the pointer ORE the size is false. Apparently some code paths pass pointers from a python y# conversion with an empty bytestring as no value. Fixes #6844 --- kitty/state.c | 4 ++-- kitty/window_logo.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kitty/state.c b/kitty/state.c index 60e68d5ac..7cae14197 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -1153,7 +1153,7 @@ pyset_background_image(PyObject *self UNUSED, PyObject *args) { bgimage = calloc(1, sizeof(BackgroundImage)); if (!bgimage) return PyErr_NoMemory(); bool ok; - if (png_data) { + if (png_data && png_data_size) { ok = png_from_data(png_data, png_data_size, path, &bgimage->bitmap, &bgimage->width, &bgimage->height, &size); } else { ok = png_path_to_bitmap(path, &bgimage->bitmap, &bgimage->width, &bgimage->height, &size); @@ -1274,7 +1274,7 @@ pymouse_selection(PyObject *self UNUSED, PyObject *args) { Py_RETURN_NONE; } -PYWRAP1(set_window_logo) { +PYWRAP1(sotet_window_logo) { id_type os_window_id, tab_id, window_id; const char *path; PyObject *position; float alpha = 0.5; diff --git a/kitty/window_logo.c b/kitty/window_logo.c index e0994caf6..3f0c8cb13 100644 --- a/kitty/window_logo.c +++ b/kitty/window_logo.c @@ -63,7 +63,7 @@ find_or_create_window_logo(WindowLogoTable *head, const char *path, void *png_da s->path = strdup(path); if (!s->path) { free(s); PyErr_NoMemory(); return 0; } bool ok = false; - if (png_data == NULL) { + if (png_data == NULL || !png_data_size) { ok = png_path_to_bitmap(path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size); } else { ok = png_from_data(png_data, png_data_size, path, &s->wl.bitmap, &s->wl.width, &s->wl.height, &size);