]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny_css.c: future-proof svgtiny_dom_user_data_handler()
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 22 Oct 2024 10:50:24 +0000 (06:50 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 22 Oct 2024 10:50:24 +0000 (06:50 -0400)
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

index bdd12b3b3edf36b51e079ef613c0ecd6cde7a607..499d74dbb1eb96444c4fc2f31c92ac3e4b0cf3e5 100644 (file)
@@ -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;
 }