Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca363be

Browse filesBrowse files
authored
Use return value of snprintf instead of calling strlen unnecessarily (#420)
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
1 parent fbe929d commit ca363be
Copy full SHA for ca363be

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎src/cxoConnection.c

Copy file name to clipboardExpand all lines: src/cxoConnection.c
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static PyObject *cxoConnection_getVersion(cxoConnection *conn, void *unused)
10501050
{
10511051
dpiVersionInfo versionInfo;
10521052
char buffer[25];
1053-
int status;
1053+
int status, len;
10541054

10551055
if (cxoConnection_isConnected(conn) < 0)
10561056
return NULL;
@@ -1059,10 +1059,11 @@ static PyObject *cxoConnection_getVersion(cxoConnection *conn, void *unused)
10591059
Py_END_ALLOW_THREADS
10601060
if (status < 0)
10611061
return cxoError_raiseAndReturnNull();
1062-
snprintf(buffer, sizeof(buffer), "%d.%d.%d.%d.%d", versionInfo.versionNum,
1063-
versionInfo.releaseNum, versionInfo.updateNum,
1064-
versionInfo.portReleaseNum, versionInfo.portUpdateNum);
1065-
return PyUnicode_DecodeASCII(buffer, strlen(buffer), NULL);
1062+
len = snprintf(buffer, sizeof(buffer), "%d.%d.%d.%d.%d",
1063+
versionInfo.versionNum, versionInfo.releaseNum,
1064+
versionInfo.updateNum, versionInfo.portReleaseNum,
1065+
versionInfo.portUpdateNum);
1066+
return PyUnicode_DecodeASCII(buffer, len, NULL);
10661067
}
10671068

10681069

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.