mirror of
https://github.com/sharkcz/rkdeveloptool.git
synced 2024-11-22 14:06:47 +01:00
Fix compilation issue in split_item().
Recent compilers complain with the following message: main.cpp: In function ‘void split_item(STRING_VECTOR&, char*)’: main.cpp:2840:10: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length This patch addresses this issue. Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
This commit is contained in:
parent
610bb714ae
commit
02bc776388
6
main.cpp
6
main.cpp
@ -2827,7 +2827,7 @@ void split_item(STRING_VECTOR &vecItems, char *pszItems)
|
||||
pStart = pszItems;
|
||||
pos = strchr(pStart, ',');
|
||||
while(pos != NULL) {
|
||||
memset(szItem, 0, 100);
|
||||
memset(szItem, 0, sizeof(szItem));
|
||||
strncpy(szItem, pStart, pos - pStart);
|
||||
strItem = szItem;
|
||||
vecItems.push_back(strItem);
|
||||
@ -2837,8 +2837,8 @@ void split_item(STRING_VECTOR &vecItems, char *pszItems)
|
||||
pos = strchr(pStart, ',');
|
||||
}
|
||||
if (strlen(pStart) > 0) {
|
||||
memset(szItem, 0, 100);
|
||||
strncpy(szItem, pStart, strlen(pStart));
|
||||
memset(szItem, 0, sizeof(szItem));
|
||||
strncpy(szItem, pStart, sizeof(szItem)-1);
|
||||
strItem = szItem;
|
||||
vecItems.push_back(strItem);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user