diff --git a/src/test/libicalvcard/vcard_test.c b/src/test/libicalvcard/vcard_test.c index 40c0a4ebf..ab18f875e 100644 --- a/src/test/libicalvcard/vcard_test.c +++ b/src/test/libicalvcard/vcard_test.c @@ -53,8 +53,12 @@ int main(int argc, const char **argv) fstat(fd, &sbuf); data = malloc(sbuf.st_size+1); - read(fd, data, sbuf.st_size); - data[sbuf.st_size] = '\0'; + int r = read(fd, data, sbuf.st_size); + if (r < 0) { + fprintf(stderr, "Failed to read vCard\n"); + return -1; + } + data[r+1] = '\0'; vcardcomponent *card = vcardparser_parse_string(data); free(data);