Skip to content

Conversation

@kzyapkov
Copy link
Contributor

I have a sketch which consistently crashes when correct HTTP credentials are provided in the Authorization header. Experiments showed that the crashes are caused by the delete[] statements for toencode and encoded. I wasn't able to decipher the core dumps.

Trial-and-error lead to the solution here. I have no explanation why it works, but definitely fixes the world for me.

@igrr
Copy link
Member

igrr commented Mar 18, 2016

I'd advise against use of VLA. Since we don't have a way to reliably catch stack overflow issues, there is no way to make sure variable-length stack allocation succeeds (and crash if it fails). So it's better to use either static fixed-length arrays or dynamically allocated arrays. I think to fix the issue it is sufficient to change +1 with +2 in toencodelen calculation.

Edit: or, rather, to maintain code style, add +1 in toencode declaration:

char *toencode = new char[toencodeLen + 1];

@igrr
Copy link
Member

igrr commented Mar 18, 2016

#1790 (comment)

@kzyapkov
Copy link
Contributor Author

Okay!

@kzyapkov kzyapkov closed this Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants