X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsvgtiny.c;h=0bcfe7daf94412c899f04b082062680553e67549;hb=15d5208a999e91c0f1edf511fd9c2b4a726aa537;hp=137f2b065d9afed42440342a3c24d781e8bcf112;hpb=461d400085eba848898d74c92a820b5e3e1d6c49;p=libsvgtiny.git diff --git a/src/svgtiny.c b/src/svgtiny.c index 137f2b0..0bcfe7d 100644 --- a/src/svgtiny.c +++ b/src/svgtiny.c @@ -42,12 +42,12 @@ static svgtiny_code svgtiny_parse_poly(dom_element *poly, struct svgtiny_parse_state state, bool polygon); static svgtiny_code svgtiny_parse_text(dom_element *text, struct svgtiny_parse_state state); -static void svgtiny_parse_position_attributes(const dom_element *node, +static void svgtiny_parse_position_attributes(dom_element *node, const struct svgtiny_parse_state state, float *x, float *y, float *width, float *height); -static void svgtiny_parse_paint_attributes(const dom_element *node, +static void svgtiny_parse_paint_attributes(dom_element *node, struct svgtiny_parse_state *state); -static void svgtiny_parse_font_attributes(const dom_element *node, +static void svgtiny_parse_font_attributes(dom_element *node, struct svgtiny_parse_state *state); static void svgtiny_parse_transform_attributes(dom_element *node, struct svgtiny_parse_state *state); @@ -1008,9 +1008,13 @@ svgtiny_code svgtiny_parse_text(dom_element *text, dom_node_unref(child); return svgtiny_LIBDOM_ERROR; } - shape->text = strndup(dom_string_data(content), - dom_string_byte_length(content)); - dom_string_unref(content); + if (content != NULL) { + shape->text = strndup(dom_string_data(content), + dom_string_byte_length(content)); + dom_string_unref(content); + } else { + shape->text = strdup(""); + } shape->text_x = px; shape->text_y = py; state.diagram->shape_count++; @@ -1035,7 +1039,7 @@ svgtiny_code svgtiny_parse_text(dom_element *text, * Parse x, y, width, and height attributes, if present. */ -void svgtiny_parse_position_attributes(const dom_element *node, +void svgtiny_parse_position_attributes(dom_element *node, const struct svgtiny_parse_state state, float *x, float *y, float *width, float *height) { @@ -1127,7 +1131,7 @@ float svgtiny_parse_length(dom_string *s, int viewport_size, * Parse paint attributes, if present. */ -void svgtiny_parse_paint_attributes(const dom_element *node, +void svgtiny_parse_paint_attributes(dom_element *node, struct svgtiny_parse_state *state) { dom_string *attr; @@ -1264,7 +1268,7 @@ void svgtiny_parse_color(dom_string *s, svgtiny_colour *c, * Parse font attributes, if present. */ -void svgtiny_parse_font_attributes(const dom_element *node, +void svgtiny_parse_font_attributes(dom_element *node, struct svgtiny_parse_state *state) { /* TODO: Implement this, it never used to be */