fix some unitialized variable use (thanks valgrind)

This commit is contained in:
Maxime Coste 2012-03-08 20:49:10 +00:00
parent 8bc6ed6cbb
commit c98657a512
2 changed files with 4 additions and 2 deletions

View File

@ -214,7 +214,7 @@ void Buffer::update_lines(const Modification& modification)
std::vector<BufferPos> new_lines; std::vector<BufferPos> new_lines;
// if we inserted at the end of the buffer, we may have created a new // if we inserted at the end of the buffer, we may have created a new
// line without inserting a '\n' // line without inserting a '\n'
if (endpos == m_content.size() and m_content[pos-1] == '\n') if (endpos == m_content.size() and pos > 0 and m_content[pos-1] == '\n')
new_lines.push_back(pos); new_lines.push_back(pos);
// every \n inserted that was not the last buffer character created a // every \n inserted that was not the last buffer character created a

View File

@ -516,7 +516,9 @@ void exec_commands_in_runtime_file(const CommandParameters& params,
const std::string& filename = params[0]; const std::string& filename = params[0];
char buffer[2048]; char buffer[2048];
#if defined(__linux__) #if defined(__linux__)
readlink("/proc/self/exe", buffer, 2048 - filename.length()); ssize_t res = readlink("/proc/self/exe", buffer, 2048 - filename.length());
assert(res != -1);
buffer[res] = '\0';
#elif defined(__APPLE__) #elif defined(__APPLE__)
uint32_t bufsize = 2048 - filename.length(); uint32_t bufsize = 2048 - filename.length();
_NSGetExecutablePath(buffer, &bufsize); _NSGetExecutablePath(buffer, &bufsize);