Skip to content

Commit

Permalink
Fix for portability case where XREALLOC is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Dec 19, 2023
1 parent b18d011 commit 97f015b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -8056,6 +8056,7 @@ int WP11_AesGcm_DecryptUpdate(unsigned char* enc, word32 encSz,
unsigned char* newEnc;
WP11_GcmParams* gcm = &session->params.gcm;

#ifdef XREALLOC
newEnc = (unsigned char*)XREALLOC(gcm->enc, gcm->encSz + encSz, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (newEnc == NULL)
Expand All @@ -8065,6 +8066,20 @@ int WP11_AesGcm_DecryptUpdate(unsigned char* enc, word32 encSz,
XMEMCPY(gcm->enc + gcm->encSz, enc, encSz);
gcm->encSz += encSz;
}
#else
newEnc = (unsigned char*)XMALLOC(gcm->encSz + encSz, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (newEnc == NULL)
ret = MEMORY_E;
if (ret == 0) {
if (gcm->enc != NULL)
XMEMCPY(newEnc, gcm->enc, gcm->encSz);
XFREE(gcm->enc, NULL, DYNAMIC_TYPE_TMP_BUFFER);
gcm->enc = newEnc;
XMEMCPY(gcm->enc + gcm->encSz, enc, encSz);
gcm->encSz += encSz;
}
#endif /* !XREALLOC */

return ret;
}
Expand Down

0 comments on commit 97f015b

Please sign in to comment.