if (buf[i] == '\n') {
if (*rows == INT_MAX) {
av_log(log_ctx, AV_LOG_ERROR, "Overflow on the number of rows in the file\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
}
++(*rows);
*cols = FFMAX(*cols, w);
if (*rows > (SIZE_MAX / sizeof(int) / *cols)) {
av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n",
*rows, *cols);
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
+ if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols))) {
+ ret = AVERROR(ENOMEM);
+ goto end;
}
- if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols)))
- return AVERROR(ENOMEM);
/* fill *values */
p = buf;
(*values)[*cols*i + j] = !!av_isgraph(*(p++));
}
}
+
+end:
av_file_unmap(buf, size);
#ifdef DEBUG