Added missing null check in C code after malloc.

pull/47/head
Project Nayuki 6 years ago
parent 04e1942b16
commit 3a28ba7dfd

@ -78,6 +78,10 @@ int main(void) {
bool ok;
if (isAscii) {
char *text = malloc((length + 1) * sizeof(char));
if (text == NULL) {
perror("malloc");
return EXIT_FAILURE;
}
for (int i = 0; i < length; i++)
text[i] = (char)data[i];
text[length] = '\0';

Loading…
Cancel
Save