Skip to content
Snippets Groups Projects
Commit e6630d8d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdiInqKeyString: set string[maxlength-1] = '\0'

parent c1095b0c
No related branches found
No related tags found
1 merge request!7Replaced gridDefDatatype()/gridInqDatatype() by cdiDefKeyInt()/cdiInqKeyInt()...
......@@ -662,10 +662,12 @@ int cdiInqKeyString(int cdiID, int varID, int key, char *string, int *length)
xassert(string != NULL);
xassert(length != NULL);
string[0] = '\0';
int maxlength = *length;
if (maxlength > 0) string[0] = '\0';
int status = cdiInqKeyBytes(cdiID, varID, key, (unsigned char *) string, length);
if (status != CDI_NOERR) *length = 0;
else string[maxlength-1] = '\0';
return status;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment