• R/O
  • SSH

libctools: Commit

This library contains code that extends and simplifies different operations
for C language based programs.


Commit MetaInfo

Revision63f8422e51784b44a3f15f06c93187680ad03e38 (tree)
Zeit2022-09-12 09:44:38
AutorSergey Gusarov <laborer2008@gmai...>
CommiterSergey Gusarov

Log Message

fixed strndup() on windows(thanks to test)

Ändern Zusammenfassung

Diff

diff -r 0131297a766c -r 63f8422e5178 src/std/string.c
--- a/src/std/string.c Mon Sep 12 02:57:29 2022 +0300
+++ b/src/std/string.c Mon Sep 12 03:44:38 2022 +0300
@@ -47,15 +47,15 @@
4747
4848 if (kLen)
4949 {
50- const size_t kFullLen = kLen + 1;
51- const size_t kAllocSize = CT_MIN2(kFullLen, n);
50+ const size_t kBytesToCopy = CT_MIN2(kLen, n);
51+ const size_t kAllocSize = kBytesToCopy + 1;
5252
5353 if (kAllocSize)
5454 {
5555 newString = (char*)malloc(kAllocSize);
5656 if (newString)
5757 {
58- strncpy(newString, s, kAllocSize);
58+ strncpy(newString, s, kBytesToCopy);
5959 newString[kAllocSize - 1] = 0;
6060 }
6161 else
Show on old repository browser