mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 15:01:21 +02:00
41096: Don't assume null termination copying string.
At this point the string may contain embedded nulls or not have a null termination at all. Also, as we always have the length memcpy() is more efficient.
This commit is contained in:
parent
1caaa933b4
commit
4bb81eefbd
@ -1,3 +1,8 @@
|
||||
2017-05-11 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 41096: Src/string.c: Fix dupstring_wlen() for unmetafied
|
||||
string. It's not safe to assume null termination.
|
||||
|
||||
2017-05-09 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* unposted: Test/D02glob.ztst: Adding comment to test changed
|
||||
|
@ -52,7 +52,8 @@ dupstring_wlen(const char *s, unsigned len)
|
||||
if (!s)
|
||||
return NULL;
|
||||
t = (char *) zhalloc(len + 1);
|
||||
strcpy(t, s);
|
||||
memcpy(t, s, len);
|
||||
t[len] = '\0';
|
||||
return t;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user