gtk_entry_buffer_normal_insert_text() requires that the chars argument must be NUL-terminated
The gtk_entry_buffer_normal_insert_text()
function takes a pointer to an array of characters and a count of the number of characters from that array to insert into the text. This function eventually calls gtk_entry_buffer_emit_inserted_text()
which in turn calls g_signal_emit()
with the array as a string argument. Providing the array as a string argument converts the array to a string, calling gstrdup()
on the array, thus requiring NUL-termination.
Typically, C functions which take a pointer to an array of characters and a character count, don't require the array to be NUL-terminated. For example, strncpy()
, strndup()
, etc. It would be good if either (1) gtk_entry_buffer_normal_insert_text()
, or the functions it calls, were modified to not require NUL-termination of the chars
argument or (2) the requirement for the chars
argument to be NUL-terminated was documented.