Github user zellerh commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/953#discussion_r100892378
--- Diff: core/sql/cli/memorymonitor.cpp ---
@@ -223,12 +229,12 @@ void MemoryMonitor::update(float &scale) {
char * currPtr;
bytesRead = fread(buffer, 1, 2048, fd_meminfo_);
// Make sure there wasn't an error (next fseek will clear eof)
- if (!feof(fd_meminfo_))// Make sure there wasn't an error
- {
- scale = 6;
- pressure_ = 0;
- return;
- }
+ if (ferror(fd_meminfo_))
+ assert(false);
+ if (feof(fd_meminfo_))
+ clearerr(fd_meminfo_);
+ else
+ buffer[bytesRead] = '\0';
--- End diff --
@selvaganesang, I like that you added the terminating \0 to the buffer
read, since we are using strstr below and since fread does not add this
terminator. My comment was that we should be doing this unconditionally,
otherwise strstr could potentially go beyond the buffer - although this is
unlikely to happen in real life.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---