summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-20 00:32:11 +0100
committerGitHub <noreply@github.com>2019-03-20 00:32:11 +0100
commitea3592d7ef6308bf9f6c7d86556f9b36f5ca0060 (patch)
tree0d2d3213c035b20212d5c098bcbb92caec44fb43 /Objects
parentf7959a9fe7e7e316899c60251e29390c4ed0307a (diff)
downloadcpython-git-ea3592d7ef6308bf9f6c7d86556f9b36f5ca0060.tar.gz
bpo-36365: Fix compiler warning in structseq.c (GH-12451)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/structseq.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 900aaba7c1..e48165dcd0 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -182,10 +182,16 @@ structseq_repr(PyStructSequence *obj)
endofbuf= &buf[REPR_BUFFER_SIZE-5];
/* "typename(", limited to TYPE_MAXSIZE */
- len = strlen(typ->tp_name) > TYPE_MAXSIZE ? TYPE_MAXSIZE :
- strlen(typ->tp_name);
- strncpy(pbuf, typ->tp_name, len);
- pbuf += len;
+ assert(TYPE_MAXSIZE < sizeof(buf));
+ len = strlen(typ->tp_name);
+ if (len <= TYPE_MAXSIZE) {
+ strcpy(pbuf, typ->tp_name);
+ pbuf += len;
+ }
+ else {
+ strncpy(pbuf, typ->tp_name, TYPE_MAXSIZE);
+ pbuf += TYPE_MAXSIZE;
+ }
*pbuf++ = '(';
for (i=0; i < VISIBLE_SIZE(obj); i++) {