Skip to content

Commit e777227

Browse files
committed
avoid null strings
1 parent 5100b17 commit e777227

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/heap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,11 @@ gboolean
10641064
heap_string_new(Heap *heap, const char *str, PElement *out)
10651065
{
10661066
PElement list = *out;
1067-
const int n = strlen(str);
1068-
int i;
10691067

10701068
heap_list_init(&list);
10711069

1072-
for (i = 0; i < n; i++) {
1070+
const int n = strlen(str);
1071+
for (int i = 0; i < n; i++) {
10731072
PElement t;
10741073

10751074
if (!heap_list_add(heap, &list, &t))
@@ -1088,7 +1087,8 @@ heap_managedstring_new(Heap *heap, const char *str, PElement *out)
10881087
{
10891088
Managedstring *managedstring;
10901089

1091-
if (strcmp(str, "") == 0) {
1090+
if (!str ||
1091+
g_str_equal(str, "")) {
10921092
PEPUTP(out, ELEMENT_ELIST, NULL);
10931093
}
10941094
else {

0 commit comments

Comments
 (0)