Skip to content

Commit 91d1c18

Browse files
committed
Revert "select: No need to NULL guard lwc_string_unref"
This reverts commit 2072074.
1 parent b926c9c commit 91d1c18

File tree

6 files changed

+88
-41
lines changed

6 files changed

+88
-41
lines changed

src/select/computed.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ css_error css_computed_style_destroy(css_computed_style *style)
192192
free(style->quotes);
193193
}
194194

195-
lwc_string_unref(style->i.list_style_image);
196-
lwc_string_unref(style->i.background_image);
195+
if (style->i.list_style_image != NULL)
196+
lwc_string_unref(style->i.list_style_image);
197+
198+
if (style->i.background_image != NULL)
199+
lwc_string_unref(style->i.background_image);
197200

198201
if (style->calc != NULL)
199202
css_calculator_unref(style->calc);

src/select/font_face.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ static void font_faces_srcs_destroy(css_font_face *font_face)
1616
css_font_face_src *srcs = font_face->srcs;
1717

1818
for (i = 0; i < font_face->n_srcs; ++i) {
19-
lwc_string_unref(srcs[i].location);
19+
if (srcs[i].location != NULL) {
20+
lwc_string_unref(srcs[i].location);
21+
}
2022
}
2123

2224
free(srcs);
@@ -67,7 +69,8 @@ css_error css__font_face_destroy(css_font_face *font_face)
6769
if (font_face == NULL)
6870
return CSS_BADPARM;
6971

70-
lwc_string_unref(font_face->font_family);
72+
if (font_face->font_family != NULL)
73+
lwc_string_unref(font_face->font_family);
7174

7275
if (font_face->srcs != NULL)
7376
font_faces_srcs_destroy(font_face);
@@ -93,7 +96,8 @@ css_error css__font_face_set_font_family(css_font_face *font_face,
9396
if (font_face == NULL || font_family == NULL)
9497
return CSS_BADPARM;
9598

96-
lwc_string_unref(font_face->font_family);
99+
if (font_face->font_family != NULL)
100+
lwc_string_unref(font_face->font_family);
97101

98102
font_face->font_family = lwc_string_ref(font_family);
99103

src/select/properties/background_image.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ css_error css__set_background_image_from_hint(const css_hint *hint,
2727

2828
error = set_background_image(style, hint->status, hint->data.string);
2929

30-
lwc_string_unref(hint->data.string);
30+
if (hint->data.string != NULL)
31+
lwc_string_unref(hint->data.string);
3132

3233
return error;
3334
}

src/select/properties/list_style_image.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ css_error css__set_list_style_image_from_hint(const css_hint *hint,
2727

2828
error = set_list_style_image(style, hint->status, hint->data.string);
2929

30-
lwc_string_unref(hint->data.string);
30+
if (hint->data.string != NULL)
31+
lwc_string_unref(hint->data.string);
3132

3233
return error;
3334
}

src/select/select.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,17 @@ static void css_select__finalise_selection_state(
10311031
}
10321032
}
10331033

1034-
lwc_string_unref(state->id);
1035-
lwc_string_unref(state->element.ns);
1036-
lwc_string_unref(state->element.name);
1034+
if (state->id != NULL) {
1035+
lwc_string_unref(state->id);
1036+
}
1037+
1038+
if (state->element.ns != NULL) {
1039+
lwc_string_unref(state->element.ns);
1040+
}
1041+
1042+
if (state->element.name != NULL){
1043+
lwc_string_unref(state->element.name);
1044+
}
10371045

10381046
if (state->revert != NULL) {
10391047
for (size_t i = 0; i < CSS_ORIGIN_AUTHOR; i++) {

src/select/strings.c

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -200,35 +200,65 @@ css_error css_select_strings_intern(css_select_strings *str)
200200

201201
void css_select_strings_unref(css_select_strings *str)
202202
{
203-
lwc_string_unref(str->universal);
204-
lwc_string_unref(str->first_child);
205-
lwc_string_unref(str->link);
206-
lwc_string_unref(str->visited);
207-
lwc_string_unref(str->hover);
208-
lwc_string_unref(str->active);
209-
lwc_string_unref(str->focus);
210-
lwc_string_unref(str->nth_child);
211-
lwc_string_unref(str->nth_last_child);
212-
lwc_string_unref(str->nth_of_type);
213-
lwc_string_unref(str->nth_last_of_type);
214-
lwc_string_unref(str->last_child);
215-
lwc_string_unref(str->first_of_type);
216-
lwc_string_unref(str->last_of_type);
217-
lwc_string_unref(str->only_child);
218-
lwc_string_unref(str->only_of_type);
219-
lwc_string_unref(str->root);
220-
lwc_string_unref(str->empty);
221-
lwc_string_unref(str->target);
222-
lwc_string_unref(str->lang);
223-
lwc_string_unref(str->enabled);
224-
lwc_string_unref(str->disabled);
225-
lwc_string_unref(str->checked);
226-
lwc_string_unref(str->first_line);
227-
lwc_string_unref(str->first_letter);
228-
lwc_string_unref(str->before);
229-
lwc_string_unref(str->after);
230-
231-
lwc_string_unref(str->width);
232-
lwc_string_unref(str->height);
233-
lwc_string_unref(str->prefers_color_scheme);
203+
if (str->universal != NULL)
204+
lwc_string_unref(str->universal);
205+
if (str->first_child != NULL)
206+
lwc_string_unref(str->first_child);
207+
if (str->link != NULL)
208+
lwc_string_unref(str->link);
209+
if (str->visited != NULL)
210+
lwc_string_unref(str->visited);
211+
if (str->hover != NULL)
212+
lwc_string_unref(str->hover);
213+
if (str->active != NULL)
214+
lwc_string_unref(str->active);
215+
if (str->focus != NULL)
216+
lwc_string_unref(str->focus);
217+
if (str->nth_child != NULL)
218+
lwc_string_unref(str->nth_child);
219+
if (str->nth_last_child != NULL)
220+
lwc_string_unref(str->nth_last_child);
221+
if (str->nth_of_type != NULL)
222+
lwc_string_unref(str->nth_of_type);
223+
if (str->nth_last_of_type != NULL)
224+
lwc_string_unref(str->nth_last_of_type);
225+
if (str->last_child != NULL)
226+
lwc_string_unref(str->last_child);
227+
if (str->first_of_type != NULL)
228+
lwc_string_unref(str->first_of_type);
229+
if (str->last_of_type != NULL)
230+
lwc_string_unref(str->last_of_type);
231+
if (str->only_child != NULL)
232+
lwc_string_unref(str->only_child);
233+
if (str->only_of_type != NULL)
234+
lwc_string_unref(str->only_of_type);
235+
if (str->root != NULL)
236+
lwc_string_unref(str->root);
237+
if (str->empty != NULL)
238+
lwc_string_unref(str->empty);
239+
if (str->target != NULL)
240+
lwc_string_unref(str->target);
241+
if (str->lang != NULL)
242+
lwc_string_unref(str->lang);
243+
if (str->enabled != NULL)
244+
lwc_string_unref(str->enabled);
245+
if (str->disabled != NULL)
246+
lwc_string_unref(str->disabled);
247+
if (str->checked != NULL)
248+
lwc_string_unref(str->checked);
249+
if (str->first_line != NULL)
250+
lwc_string_unref(str->first_line);
251+
if (str->first_letter != NULL)
252+
lwc_string_unref(str->first_letter);
253+
if (str->before != NULL)
254+
lwc_string_unref(str->before);
255+
if (str->after != NULL)
256+
lwc_string_unref(str->after);
257+
258+
if (str->width != NULL)
259+
lwc_string_unref(str->width);
260+
if (str->height != NULL)
261+
lwc_string_unref(str->height);
262+
if (str->prefers_color_scheme != NULL)
263+
lwc_string_unref(str->prefers_color_scheme);
234264
}

0 commit comments

Comments
 (0)