提交 bd99bde9 编写于 作者: H Haojun Liao

[TD-2752]<fix>: check if the FILE pointer is valid or not.

上级 52a52462
...@@ -6928,11 +6928,12 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) { ...@@ -6928,11 +6928,12 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
*/ */
if (isTSCompQuery(pQuery) && (*numOfRows) > 0) { if (isTSCompQuery(pQuery) && (*numOfRows) > 0) {
struct stat fStat; struct stat fStat;
if (fstat(fileno(*(FILE **)pQuery->sdata[0]->data), &fStat) == 0) { FILE *f = *(FILE **)pQuery->sdata[0]->data;
if ((f != NULL) && (fstat(fileno(f), &fStat) == 0)) {
*numOfRows = fStat.st_size; *numOfRows = fStat.st_size;
return fStat.st_size; return fStat.st_size;
} else { } else {
qError("QInfo:%p failed to get file info, path:%s, reason:%s", pQInfo, pQuery->sdata[0]->data, strerror(errno)); qError("QInfo:%p failed to get file info, file:%p, reason:%s", pQInfo, f, strerror(errno));
return 0; return 0;
} }
} else { } else {
...@@ -6947,7 +6948,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) { ...@@ -6947,7 +6948,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// load data from file to msg buffer // load data from file to msg buffer
if (isTSCompQuery(pQuery)) { if (isTSCompQuery(pQuery)) {
FILE *f = *(FILE **)pQuery->sdata[0]->data; FILE *f = *(FILE **)pQuery->sdata[0]->data; // TODO refactor
// make sure file exist // make sure file exist
if (f) { if (f) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册