Skip to content
Snippets Groups Projects
Commit b29d4375 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Finish fixing ini*SString().

The first fix was to copy the right value, the second fix was to
ensure zero-length strings are terminated.
parent 4fd02c4e
No related branches found
No related tags found
No related merge requests found
Pipeline #5882 passed
...@@ -1025,13 +1025,14 @@ char* iniReadSString(FILE* fp, const char* section, const char* key, const char* ...@@ -1025,13 +1025,14 @@ char* iniReadSString(FILE* fp, const char* section, const char* key, const char*
if (sz < 1 || value == NULL) if (sz < 1 || value == NULL)
return NULL; return NULL;
for (pos = 0; ret[pos]; pos++) { for (pos = 0; ret[pos]; pos++) {
if (pos == sz - 1) { if (pos == sz - 1)
value[pos] = 0;
break; break;
}
value[pos] = ret[pos]; value[pos] = ret[pos];
} }
value[pos] = 0;
if (ret == fval)
return value; return value;
return ret;
} }
/* Does NOT support string literals: */ /* Does NOT support string literals: */
...@@ -1071,12 +1072,11 @@ char* iniGetSString(str_list_t list, const char* section, const char* key, const ...@@ -1071,12 +1072,11 @@ char* iniGetSString(str_list_t list, const char* section, const char* key, const
if (sz < 1 || value == NULL) if (sz < 1 || value == NULL)
return ret; return ret;
for (pos = 0; ret[pos]; pos++) { for (pos = 0; ret[pos]; pos++) {
if (pos == sz - 1) { if (pos == sz - 1)
value[pos] = 0;
break; break;
}
value[pos] = ret[pos]; value[pos] = ret[pos];
} }
value[pos] = 0;
if (ret == fval) if (ret == fval)
return value; return value;
return ret; return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment