Skip to content
Snippets Groups Projects
Commit 5d3fa03a authored by deuce's avatar deuce
Browse files

Fix SAFECOPY() macro to not copy if src==dst (Found by Valgrind)

parent d267eda2
Branches
Tags
No related merge requests found
...@@ -237,7 +237,7 @@ typedef struct { ...@@ -237,7 +237,7 @@ typedef struct {
#ifdef SAFECOPY_USES_SPRINTF #ifdef SAFECOPY_USES_SPRINTF
#define SAFECOPY(dst,src) sprintf(dst,"%.*s",(int)sizeof(dst)-1,src) #define SAFECOPY(dst,src) sprintf(dst,"%.*s",(int)sizeof(dst)-1,src)
#else #else
#define SAFECOPY(dst,src) (strncpy(dst,src,sizeof(dst)), dst[(int)sizeof(dst)-1]=0) #define SAFECOPY(dst,src) (((dst)==(src))?0:(strncpy(dst,src,sizeof(dst)), dst[(int)sizeof(dst)-1]=0))
#endif #endif
#define TERMINATE(str) str[sizeof(str)-1]=0 #define TERMINATE(str) str[sizeof(str)-1]=0
#if (defined __FreeBSD__) || (defined __NetBSD__) || (defined __OpenBSD__) || (defined(__APPLE__) && defined(__MACH__) && defined(__POWERPC__)) #if (defined __FreeBSD__) || (defined __NetBSD__) || (defined __OpenBSD__) || (defined(__APPLE__) && defined(__MACH__) && defined(__POWERPC__))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment