Memory allocation
fugasjunior opened this issue · comments
Hello,
I don't know it it was just me, but when I tried to use this code in C++, it kept crashing in the rsa_modExp function. After hours of debugging, I found this line of code:
long long *encrypted = malloc(sizeof(long long)*message_size);
This seemed suspicious to me, so I decided to change it to:
long long *encrypted;
encrypted = (long long*)malloc(sizeof(long long)*message_size);
(this kind of code appeared multiple times, I changed it everywhere)
and suddenly, the code started working.
EDIT: Unfortunately, after further testing, it keeps crashing completely randomly.