should use memset to init pReader

pull/484/head
YuQing 2019-12-05 09:51:36 +08:00
parent 6bfb8215ff
commit a424a06cf3
2 changed files with 9 additions and 17 deletions

View File

@ -4,7 +4,8 @@ Version 6.04 2019-12-05
* use get_gzip_command_filename from libfastcommon v1.42 * use get_gzip_command_filename from libfastcommon v1.42
* support compress error log and access log * support compress error log and access log
* disk recovery support multi-threads to speed up * disk recovery support multi-threads to speed up
* bugfix: init pReader->binlog_buff.version/length to 0 * bugfix: should use memset to init pReader in function
storage_reader_init, this bug is caused by v6.01
NOTE: you MUST upgrade libfastcommon to V1.42 or later NOTE: you MUST upgrade libfastcommon to V1.42 or later

View File

@ -2198,26 +2198,17 @@ int storage_reader_init(FDFSStorageBrief *pStorage, StorageBinLogReader *pReader
bool bFileExist; bool bFileExist;
bool bNeedSyncOld; bool bNeedSyncOld;
pReader->binlog_index = 0; memset(pReader, 0, sizeof(StorageBinLogReader));
pReader->binlog_offset = 0; pReader->binlog_fd = -1;
pReader->need_sync_old = 0;
pReader->sync_old_done = 0;
pReader->until_timestamp = 0;
pReader->scan_row_count = 0;
pReader->sync_row_count = 0;
pReader->last_file_exist = 0;
pReader->binlog_fd = -1;
pReader->binlog_buff.version = 0;
pReader->binlog_buff.length = 0;
pReader->binlog_buff.buffer = (char *)malloc( \ pReader->binlog_buff.buffer = (char *)malloc(
STORAGE_BINLOG_BUFFER_SIZE); STORAGE_BINLOG_BUFFER_SIZE);
if (pReader->binlog_buff.buffer == NULL) if (pReader->binlog_buff.buffer == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"malloc %d bytes fail, " \ "malloc %d bytes fail, "
"errno: %d, error info: %s", \ "errno: %d, error info: %s",
__LINE__, STORAGE_BINLOG_BUFFER_SIZE, \ __LINE__, STORAGE_BINLOG_BUFFER_SIZE,
errno, STRERROR(errno)); errno, STRERROR(errno));
return errno != 0 ? errno : ENOMEM; return errno != 0 ? errno : ENOMEM;
} }