Skip to content

Commit

Permalink
[refactor] safety....
Browse files Browse the repository at this point in the history
  • Loading branch information
lvntky committed Aug 11, 2024
1 parent 5bd6f54 commit 8896d89
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/ccontainer/cc_linkedlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ cc_linkedlist_node_t *cc_linkedlist_create_node(void *data, size_t data_size)
new_node->data = malloc(data_size);
new_node->next = NULL;

memcpy(new_node->data, data, data_size);
if (sizeof(new_node->data) >= sizeof(data)) {
memcpy(new_node->data, data, data_size);
} else {
CC_LINKEDLIST_LOG(
"The destination node should be bigger or equal than source node. Terminating program with failing exit status.");
exit(EXIT_FAILURE);
}

return new_node;
}
Expand Down

0 comments on commit 8896d89

Please sign in to comment.