Secure coding: Difference between revisions

Content deleted Content added
m Reverted edits by Nehirdemir (talk): disruptive edits (HG) (3.3.5)
Fixed a bug in the "secure_copy" function. strlen returns size_t and not int.
Line 26:
</syntaxhighlight>Another secure alternative is to dynamically allocate memory on the heap using [[malloc]].<syntaxhighlight lang="c++">
char * secure_copy(char * src) {
intsize_t len = strlen(src);
char * dst = (char *) malloc(len + 1);
if(dst != NULL){