Skip to content
Permalink
Browse files

Fix GCC 8 -Wstringop-truncation

If strncpy() truncates the string due to insufficient destination
buffer, it will not NUL-terminate the destination string.
9faaea3 ensured that the
destination string will always be NUL-terminated, by writing a NUL to
the end of the buffer.

But, it failed to silence a -Wstringop-truncation warning.
This fix (which should be non-functional) actually does that.
  • Loading branch information
dr-m committed Sep 4, 2019
1 parent 9faaea3 commit de57d6ada5d3b2c91e56bbc466ac3daf308b4e88
Showing with 1 addition and 1 deletion.
  1. +1 −1 include/mariadb_stmt.h
@@ -39,7 +39,7 @@
(a)->last_errno= (b);\
strncpy((a)->sqlstate, (c), SQLSTATE_LENGTH);\
(a)->sqlstate[SQLSTATE_LENGTH]= 0;\
strncpy((a)->last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE - 1);\
strncpy((a)->last_error, (d) ? (d) : ER((b)), MYSQL_ERRMSG_SIZE);\
(a)->last_error[MYSQL_ERRMSG_SIZE - 1]= 0;\
}

0 comments on commit de57d6a

Please sign in to comment.
You can’t perform that action at this time.