Skip to content

Commit ec8acc9

Browse files
committed
Fix memory allocation for wpe_pasteboard_string
The "data" member of wpe_pasteboard_string is a dynamically allocated array of characters, and allocated size must be "sizeof(char) * in_length". Also, calloc() already computes the final size itself, so pass the "in_length" parameter as the number of elements, and "sizeof(char)" as the element size.
1 parent 4b9fd32 commit ec8acc9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pasteboard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ wpe_pasteboard_string_initialize(struct wpe_pasteboard_string* string, const cha
3636
if (string->data)
3737
return;
3838

39-
string->data = calloc(1, sizeof(char*) * in_length);
39+
string->data = calloc(in_length, sizeof(char));
4040
string->length = in_length;
4141
memcpy(string->data, in_string, in_length);
4242
}

0 commit comments

Comments
 (0)