have allocate extra byte in case user wants to null terminate returned plaintext

This commit is contained in:
toddouska
2015-10-23 16:38:59 -07:00
parent d53b6a9132
commit ab68f38236

View File

@ -3078,7 +3078,9 @@ doPart:
TraceGotData(ret);
if (ret) { /* may be blank message */
byte* tmpData; /* don't leak on realloc free */
tmpData = (byte*)realloc(*data, decoded + ret);
/* add an extra byte at end of allocation in case user
* wants to null terminate plaintext */
tmpData = (byte*)realloc(*data, decoded + ret + 1);
if (tmpData == NULL) {
free(*data);
*data = NULL;