Fix a file descriptor leak and a crash in linux getMemRanges.

develop
Alexander Gavrilov 2012-09-14 12:35:55 +04:00
parent aaf5d181bd
commit d22591e240
2 changed files with 7 additions and 2 deletions

@ -127,6 +127,9 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
char permissions[5]; // r/-, w/-, x/-, p/s, 0 char permissions[5]; // r/-, w/-, x/-, p/s, 0
FILE *mapFile = ::fopen("/proc/self/maps", "r"); FILE *mapFile = ::fopen("/proc/self/maps", "r");
if (!mapFile)
return;
size_t start, end, offset, device1, device2, node; size_t start, end, offset, device1, device2, node;
while (fgets(buffer, 1024, mapFile)) while (fgets(buffer, 1024, mapFile))
@ -148,6 +151,8 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
temp.valid = true; temp.valid = true;
ranges.push_back(temp); ranges.push_back(temp);
} }
fclose(mapFile);
} }
uint32_t Process::getBase() uint32_t Process::getBase()

@ -89,10 +89,10 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes rendering of creature weight limits in pressure plate build menu.\n" " Fixes rendering of creature weight limits in pressure plate build menu.\n"
" tweak stable-temp [disable]\n" " tweak stable-temp [disable]\n"
" Fixes performance bug 6012 by squashing jitter in temperature updates.\n" " Fixes performance bug 6012 by squashing jitter in temperature updates.\n"
" tweak fast-heat [max-ticks]\n" " tweak fast-heat <max-ticks>\n"
" Further improves temperature updates by ensuring that 1 degree of\n" " Further improves temperature updates by ensuring that 1 degree of\n"
" item temperature is crossed in no more than specified number of frames\n" " item temperature is crossed in no more than specified number of frames\n"
" when updating from the environment temperature.\n" " when updating from the environment temperature. Use 0 to disable.\n"
)); ));
return CR_OK; return CR_OK;
} }