Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewer: Fix some compiler warnings (-Wstringop-truncation) #1399

Merged
merged 1 commit into from
Mar 18, 2018

Conversation

stweil
Copy link
Member

@stweil stweil commented Mar 18, 2018

gcc warnings:

viewer/scrollview.cpp:72:10: warning:
‘char* strncpy(char*, const char*, size_t)’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
viewer/scrollview.cpp:118:14: warning:
‘char* strncpy(char*, const char*, size_t)’ specified bound depends on
the length of the source argument [-Wstringop-overflow=]
viewer/scrollview.cpp:746:10: warning:
‘char* strncpy(char*, const char*, size_t)’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
viewer/scrollview.cpp:830:10: warning:
‘char* strncpy(char*, const char*, size_t)’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]

Signed-off-by: Stefan Weil sw@weilnetz.de

gcc warnings:

viewer/scrollview.cpp:72:10: warning:
 ‘char* strncpy(char*, const char*, size_t)’ output truncated before
 terminating nul copying as many bytes from a string as its length
 [-Wstringop-truncation]
viewer/scrollview.cpp:118:14: warning:
 ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on
 the length of the source argument [-Wstringop-overflow=]
viewer/scrollview.cpp:746:10: warning:
 ‘char* strncpy(char*, const char*, size_t)’ output truncated before
 terminating nul copying as many bytes from a string as its length
 [-Wstringop-truncation]
viewer/scrollview.cpp:830:10: warning:
 ‘char* strncpy(char*, const char*, size_t)’ output truncated before
 terminating nul copying as many bytes from a string as its length
 [-Wstringop-truncation]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
@@ -115,7 +114,7 @@ void* ScrollView::MessageReceiver(void* a) {

if (cur->window != NULL) {
cur->parameter = new char[strlen(p) + 1];
strncpy(cur->parameter, p, strlen(p) + 1);
strcpy(cur->parameter, p);
if (strlen(p) > 0) { // remove the last \n
cur->parameter[strlen(p)] = '\0';
Copy link
Member Author

@stweil stweil Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code in lines 118 and 119 looks strange as it does not do what the comment claims. It writes a 0 to a byte which is already 0.

@zdenop zdenop merged commit 6b2a090 into tesseract-ocr:master Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants