Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Persistence: Do not let the string default value be NULL.
Browse files Browse the repository at this point in the history
By doing so, the value variable at persist_do() will never be NULL.

Signed-off-by: Guilherme Iscaro <[email protected]>
  • Loading branch information
cabelitos committed Mar 30, 2016
1 parent bc87c97 commit 5daa00e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/modules/flow/persistence/persistence.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ persist_do(struct persist_data *mdata, struct sol_flow_node *node, void *value,
else
size = strlen(value) + 1; //To include the null terminating char

if (mdata->value_ptr && value) {
if (mdata->value_ptr) {
if (mdata->packet_data_size)
r = memcmp(mdata->value_ptr, value, mdata->packet_data_size);
else
Expand Down Expand Up @@ -676,10 +676,8 @@ persist_string_open(struct sol_flow_node *node,
SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(options,
SOL_FLOW_NODE_TYPE_PERSISTENCE_STRING_OPTIONS_API_VERSION, -EINVAL);

if (opts->default_value) {
mdata->default_value = strdup((char *)opts->default_value);
SOL_NULL_CHECK(mdata->default_value, -ENOMEM);
}
mdata->default_value = strdup(opts->default_value);
SOL_NULL_CHECK(mdata->default_value, -ENOMEM);

r = persist_open(node, data, opts->storage, opts->name);
if (r < 0)
Expand Down

0 comments on commit 5daa00e

Please sign in to comment.