mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-09-08 06:07:32 +02:00
replace strncpy by memcpy to prevent valgrind error message
on uninitialized string.
This commit is contained in:
+3
-3
@@ -73,10 +73,10 @@ int prefix_n(size_t n_char_prefix, const char *prefix,
|
||||
*/
|
||||
char *dup_string(const char *str, size_t n_char)
|
||||
{
|
||||
char *p;
|
||||
char *p = TMALLOC(char, n_char + 1);
|
||||
|
||||
if ((p = TMALLOC(char, n_char + 1)) != NULL) {
|
||||
(void) strncpy(p, str, n_char + 1);
|
||||
if (p != NULL) {
|
||||
(void) memcpy(p, str, n_char + 1);
|
||||
p[n_char] = '\0';
|
||||
}
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user