Updated freerdp_settings_set_string

Allow NULL argument with length, creates an empty string
This commit is contained in:
akallabeth 2021-11-24 13:32:44 +01:00 committed by akallabeth
parent 0577d7a0c3
commit 94685c9482
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,12 @@ static BOOL update_string(char** current, const char* next, size_t next_len, BOO
free(*current); free(*current);
} }
if (!next && (next_len > 0))
{
*current = calloc(next_len, 1);
return (*current != NULL);
}
*current = (next ? strndup(next, next_len) : NULL); *current = (next ? strndup(next, next_len) : NULL);
return !next || (*current != NULL); return !next || (*current != NULL);
} }

View File

@ -428,6 +428,12 @@ try:
f.write('\t\tfree(*current);\n') f.write('\t\tfree(*current);\n')
f.write('\t}\n') f.write('\t}\n')
f.write('\n') f.write('\n')
f.write('\tif (!next && (next_len > 0))\n')
f.write('\t{\n')
f.write('\t\t*current = calloc(next_len, 1);\n')
f.write('\t\treturn (*current != NULL);\n')
f.write('\t}\n')
f.write('\n')
f.write('\t*current = (next ? strndup(next, next_len) : NULL);\n') f.write('\t*current = (next ? strndup(next, next_len) : NULL);\n')
f.write('\treturn !next || (*current != NULL);\n') f.write('\treturn !next || (*current != NULL);\n')
f.write('}\n\n') f.write('}\n\n')