Skip to content

Commit

Permalink
status: fix bson_t detection
Browse files Browse the repository at this point in the history
Use the correct type for memset() and pre-check for NULL when calling
bson_free() which doesn't always like NULL values.

Fixes #257
  • Loading branch information
ThomasAdam committed Oct 15, 2020
1 parent a02c4ee commit b198272
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fvwm/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ status_send(void)
if (status_fp == NULL)
return;

memset(desktops, 0, sizeof desktops[0]);
memset(individual_d, 0, sizeof individual_d[0]);
memset(desktops, 0, sizeof(bson_t));
memset(individual_d, 0, sizeof(bson_t));
memset(desk_doc, 0, sizeof(bson_t));

m_cur = monitor_get_current();

Expand Down Expand Up @@ -193,11 +194,11 @@ status_send(void)
out:
bson_free(as_json);
for (i = 0; i < d_count; i++) {
if (desk_doc[i])
if (desk_doc[i] != NULL)
bson_free(desk_doc[i]);
if (desktops[i])
if (desktops[i] != NULL)
bson_free(desktops[i]);
if (individual_d[i])
if (individual_d[i] != NULL)
bson_free(individual_d[i]);
}
bson_destroy(&msg);
Expand Down

0 comments on commit b198272

Please sign in to comment.