mpit: fix behavior when returning strings
This commit was SVN r28804.
Этот коммит содержится в:
родитель
e6e9f2c6fd
Коммит
38bcbc4696
@ -57,12 +57,16 @@ static inline void mpit_copy_string (char *dest, int *len, const char *source)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0 != *len && NULL != dest) {
|
||||||
if ((int) strlen (source) < *len) {
|
if ((int) strlen (source) < *len) {
|
||||||
*len = strlen (source) + 1;
|
*len = strlen (source) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy (dest, source, *len);
|
strncpy (dest, source, *len);
|
||||||
dest[*len - 1] = '\0';
|
dest[*len - 1] = '\0';
|
||||||
|
} else {
|
||||||
|
*len = strlen (source) + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined(MPIT_INTERNAL_H) */
|
#endif /* !defined(MPIT_INTERNAL_H) */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user