Merge pull request #55 from DeforaNetworks/khorben/malloc-check

Check malloc() for errors
This commit is contained in:
Peter Goodman 2018-03-15 19:48:59 +08:00 committed by GitHub
commit f1ba0ff2f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,6 +152,9 @@ char *DeepState_CStr(size_t len) {
DeepState_Abandon("Can't create an SIZE_MAX-length string.");
}
char *str = (char *) malloc(sizeof(char) * (len + 1));
if (NULL == str) {
DeepState_Abandon("Can't allocate memory.");
}
if (len) {
DeepState_SymbolizeData(str, &(str[len - 1]));
}