mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[sanitize] some fixes for issues found in the address sanitizer
This commit is contained in:
parent
a4faac4628
commit
af36896f50
@ -85,6 +85,8 @@ std::string log_vtab_impl::get_table_statement(void)
|
||||
auto_mem<char, sqlite3_free> colname;
|
||||
string comment;
|
||||
|
||||
require(!iter->vc_name.empty());
|
||||
|
||||
if (!iter->vc_comment.empty()) {
|
||||
comment.append(" -- ")
|
||||
.append(iter->vc_comment);
|
||||
|
@ -153,7 +153,9 @@ bool logfile::process_prefix(off_t offset, shared_buffer_ref &sbr)
|
||||
bool retval = false;
|
||||
|
||||
if (this->lf_format.get() != NULL) {
|
||||
prescan_time = this->lf_index[0].get_time();
|
||||
if (!this->lf_index.empty()) {
|
||||
prescan_time = this->lf_index[0].get_time();
|
||||
}
|
||||
/* We've locked onto a format, just use that scanner. */
|
||||
found = this->lf_format->scan(this, this->lf_index, offset, sbr);
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ bool sql_ident_needs_quote(const char *ident)
|
||||
char *sql_quote_ident(const char *ident)
|
||||
{
|
||||
bool needs_quote = false;
|
||||
size_t quote_count = 0;
|
||||
size_t quote_count = 0, alloc_size;
|
||||
char *retval;
|
||||
|
||||
for (int lpc = 0; ident[lpc]; lpc++) {
|
||||
@ -572,13 +572,13 @@ char *sql_quote_ident(const char *ident)
|
||||
(!isalnum(ident[lpc]) && ident[lpc] != '_')) {
|
||||
needs_quote = true;
|
||||
}
|
||||
else if (ident[lpc] == '"') {
|
||||
if (ident[lpc] == '"') {
|
||||
quote_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((retval = (char *)sqlite3_malloc(
|
||||
strlen(ident) + quote_count * 2 + (needs_quote ? 2: 0) + 1)) == NULL) {
|
||||
alloc_size = strlen(ident) + quote_count * 2 + (needs_quote ? 2: 0) + 1;
|
||||
if ((retval = (char *)sqlite3_malloc(alloc_size)) == NULL) {
|
||||
retval = NULL;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user