From edc36f5ff3122f012f3112a65ccb75956548c9e0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 22 Oct 2024 06:50:24 -0400 Subject: [PATCH] src/svgtiny_css.c: future-proof svgtiny_dom_user_data_handler() Although dom_node_set_user_data() can only return two values (OK, and out-of-memory) at the moment, it may return others in the future. We now catch all other return values and convert them into CSS_INVALID. --- src/svgtiny_css.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/svgtiny_css.c b/src/svgtiny_css.c index bdd12b3..499d74d 100644 --- a/src/svgtiny_css.c +++ b/src/svgtiny_css.c @@ -1981,7 +1981,8 @@ static void svgtiny_dom_user_data_handler(dom_node_operation operation, * \param node Libdom SVG node on which to store the data * \param libcss_node_data Pointer to the data to store * - * \return CSS_OK on success, or CSS_NOMEM on error + * \return CSS_OK on success, CSS_NOMEM if libdom runs out of memory, + * or CSS_INVALID if any other error occurs */ css_error set_libcss_node_data(void *pw, void *node, void *libcss_node_data) @@ -2002,9 +2003,10 @@ css_error set_libcss_node_data(void *pw, void *node, if (err == DOM_NO_MEM_ERR) { return CSS_NOMEM; } + else if (err != DOM_NO_ERR) { + return CSS_INVALID; + } - /* dom_node_set_user_data() only has two return values, okay - and not-okay. */ return CSS_OK; } -- 2.49.0