mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
string: Reformat ssh_string_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
25
src/string.c
25
src/string.c
@@ -50,22 +50,23 @@
|
||||
*
|
||||
* @return The newly allocated string, NULL on error.
|
||||
*/
|
||||
struct ssh_string_struct *ssh_string_new(size_t size) {
|
||||
struct ssh_string_struct *str = NULL;
|
||||
struct ssh_string_struct *ssh_string_new(size_t size)
|
||||
{
|
||||
struct ssh_string_struct *str = NULL;
|
||||
|
||||
if (size > UINT_MAX - sizeof(struct ssh_string_struct)) {
|
||||
return NULL;
|
||||
}
|
||||
if (size > UINT_MAX - sizeof(struct ssh_string_struct)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
str = malloc(sizeof(struct ssh_string_struct) + size);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
str = malloc(sizeof(struct ssh_string_struct) + size);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
str->size = htonl(size);
|
||||
str->data[0] = 0;
|
||||
str->size = htonl(size);
|
||||
str->data[0] = 0;
|
||||
|
||||
return str;
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user