mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Fix segfault in str(n)dup function.
This commit is contained in:
parent
33aa3abd96
commit
bccadc7d67
1 changed files with 6 additions and 0 deletions
|
@ -52,6 +52,9 @@ void *c_realloc(void *ptr, size_t size) {
|
|||
char *c_strdup(const char *str) {
|
||||
char *ret;
|
||||
ret = (char *) c_malloc(strlen(str) + 1);
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(ret, str);
|
||||
return ret;
|
||||
}
|
||||
|
@ -64,6 +67,9 @@ char *c_strndup(const char *str, size_t size) {
|
|||
len = size;
|
||||
}
|
||||
ret = (char *) c_malloc(len + 1);
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(ret, str, len);
|
||||
ret[size] = '\0';
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue