We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3947

Summary: replace strlcpy with memcpy in SDL_strdup()
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   

Description Ozkan Sezer 2017-11-06 19:38:25 UTC
The following patch replaces SDL_strlcpy() with SDL_memcpy()
in SDL_strdup(), which should be more efficient.

diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c
--- a/src/stdlib/SDL_string.c
+++ b/src/stdlib/SDL_string.c
@@ -564,7 +564,7 @@ SDL_strdup(const char *string)
     size_t len = SDL_strlen(string) + 1;
     char *newstr = SDL_malloc(len);
     if (newstr) {
-        SDL_strlcpy(newstr, string, len);
+        SDL_memcpy(newstr, string, len);
     }
     return newstr;
 }
Comment 1 Sam Lantinga 2018-02-13 16:13:55 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/68864895c386