Skip to content

[3.7] Fix compiler warning in call_readline() (GH-10820)#12452

Merged
vstinner merged 1 commit intopython:3.7from
vstinner:readline37
Mar 20, 2019
Merged

[3.7] Fix compiler warning in call_readline() (GH-10820)#12452
vstinner merged 1 commit intopython:3.7from
vstinner:readline37

Conversation

@vstinner
Copy link
Copy Markdown
Member

Replace strncpy() with memcpy() in call_readline() to fix the
following warning, the NUL byte is written manually just after:

Modules/readline.c: In function ‘call_readline’:
Modules/readline.c:1303:9: warning: ‘strncpy’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
strncpy(p, q, n);
^~~~~~~~~~~~~~~~
Modules/readline.c:1279:9: note: length computed here
n = strlen(p);
^~~~~~~~~

(cherry picked from commit 1600f60)

Replace strncpy() with memcpy() in call_readline() to fix the
following warning, the NUL byte is written manually just after:

Modules/readline.c: In function ‘call_readline’:
Modules/readline.c:1303:9: warning: ‘strncpy’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
         strncpy(p, q, n);
         ^~~~~~~~~~~~~~~~
Modules/readline.c:1279:9: note: length computed here
     n = strlen(p);
         ^~~~~~~~~

(cherry picked from commit 1600f60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants