Changed strcpy() to strncpy(). Let's build on Windows!
This commit is contained in:
parent
1814745646
commit
664cf26cdc
|
@ -52,9 +52,11 @@ int testingprivSnprintf(char *s, size_t n, const char *format, ...)
|
||||||
char *testingprivStrdup(const char *s)
|
char *testingprivStrdup(const char *s)
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
t = (char *) testingprivAlloc((strlen(s) + 1) * sizeof (char), "char[]");
|
n = strlen(s);
|
||||||
strcpy(t, s);
|
t = (char *) testingprivAlloc((n + 1) * sizeof (char), "char[]");
|
||||||
|
strncpy(t, s, n + 1);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,23 +19,27 @@ static bool memoryExhausted = false;
|
||||||
|
|
||||||
static void catalogProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
static void catalogProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
||||||
{
|
{
|
||||||
|
size_t n;
|
||||||
|
|
||||||
current->caught = true;
|
current->caught = true;
|
||||||
if (strstr(prefix, "programmer error") == NULL) {
|
if (strstr(prefix, "programmer error") == NULL) {
|
||||||
current->prefixGot = (char *) malloc((strlen(prefix) + 1) * sizeof (char));
|
n = strlen(prefix);
|
||||||
|
current->prefixGot = (char *) malloc((n + 1) * sizeof (char));
|
||||||
if (current->prefixGot == NULL) {
|
if (current->prefixGot == NULL) {
|
||||||
memoryExhausted = true;
|
memoryExhausted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(current->prefixGot, prefix);
|
strncpy(current->prefixGot, prefix, n + 1);
|
||||||
}
|
}
|
||||||
current->internalGot = internal;
|
current->internalGot = internal;
|
||||||
if (strstr(msg, current->msgWant) == NULL) {
|
if (strstr(msg, current->msgWant) == NULL) {
|
||||||
current->msgGot = (char *) malloc((strlen(msg) + 1) * sizeof (char));
|
n = strlen(msg);
|
||||||
|
current->msgGot = (char *) malloc((n + 1) * sizeof (char));
|
||||||
if (current->msgGot == NULL) {
|
if (current->msgGot == NULL) {
|
||||||
memoryExhausted = true;
|
memoryExhausted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(current->msgGot, msg);
|
strncpy(current->msgGot, msg, n + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue