* Fix up bad accesses found by valgrind.
This commit is contained in:
parent
fa37df8b1f
commit
035fd35ffd
14
minidlna.c
14
minidlna.c
@ -312,7 +312,7 @@ getfriendlyname(char * buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
open_db(void)
|
open_db(sqlite3 **thisdb)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int new_db = 0;
|
int new_db = 0;
|
||||||
@ -327,11 +327,14 @@ open_db(void)
|
|||||||
{
|
{
|
||||||
DPRINTF(E_FATAL, L_GENERAL, "ERROR: Failed to open sqlite database! Exiting...\n");
|
DPRINTF(E_FATAL, L_GENERAL, "ERROR: Failed to open sqlite database! Exiting...\n");
|
||||||
}
|
}
|
||||||
|
if (thisdb)
|
||||||
|
*thisdb = db;
|
||||||
sqlite3_busy_timeout(db, 5000);
|
sqlite3_busy_timeout(db, 5000);
|
||||||
sql_exec(db, "pragma page_size = 4096");
|
sql_exec(db, "pragma page_size = 4096");
|
||||||
sql_exec(db, "pragma journal_mode = OFF");
|
sql_exec(db, "pragma journal_mode = OFF");
|
||||||
sql_exec(db, "pragma synchronous = OFF;");
|
sql_exec(db, "pragma synchronous = OFF;");
|
||||||
sql_exec(db, "pragma default_cache_size = 8192;");
|
sql_exec(db, "pragma default_cache_size = 8192;");
|
||||||
|
|
||||||
return new_db;
|
return new_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,14 +376,14 @@ check_db(sqlite3 *db, int new_db, pid_t *scanner_pid)
|
|||||||
if( system(cmd) != 0 )
|
if( system(cmd) != 0 )
|
||||||
DPRINTF(E_FATAL, L_GENERAL, "Failed to clean old file cache! Exiting...\n");
|
DPRINTF(E_FATAL, L_GENERAL, "Failed to clean old file cache! Exiting...\n");
|
||||||
|
|
||||||
open_db();
|
open_db(&db);
|
||||||
if( CreateDatabase() != 0 )
|
if( CreateDatabase() != 0 )
|
||||||
DPRINTF(E_FATAL, L_GENERAL, "ERROR: Failed to create sqlite database! Exiting...\n");
|
DPRINTF(E_FATAL, L_GENERAL, "ERROR: Failed to create sqlite database! Exiting...\n");
|
||||||
#if USE_FORK
|
#if USE_FORK
|
||||||
scanning = 1;
|
scanning = 1;
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
*scanner_pid = fork();
|
*scanner_pid = fork();
|
||||||
open_db();
|
open_db(&db);
|
||||||
if( !(*scanner_pid) ) // child (scanner) process
|
if( !(*scanner_pid) ) // child (scanner) process
|
||||||
{
|
{
|
||||||
start_scanner();
|
start_scanner();
|
||||||
@ -1102,10 +1105,9 @@ main(int argc, char * * argv)
|
|||||||
|
|
||||||
LIST_INIT(&upnphttphead);
|
LIST_INIT(&upnphttphead);
|
||||||
|
|
||||||
if( (i = open_db()) == 0 )
|
i = open_db(NULL);
|
||||||
{
|
if( i == 0 )
|
||||||
updateID = sql_get_int_field(db, "SELECT UPDATE_ID from SETTINGS");
|
updateID = sql_get_int_field(db, "SELECT UPDATE_ID from SETTINGS");
|
||||||
}
|
|
||||||
check_db(db, i, &scanner_pid);
|
check_db(db, i, &scanner_pid);
|
||||||
signal(SIGCHLD, &sigchld);
|
signal(SIGCHLD, &sigchld);
|
||||||
#ifdef HAVE_INOTIFY
|
#ifdef HAVE_INOTIFY
|
||||||
|
@ -204,7 +204,7 @@ _get_wavtags(char *filename, struct song_metadata *psong)
|
|||||||
p += taglen + 8;
|
p += taglen + 8;
|
||||||
off += taglen + 8;
|
off += taglen + 8;
|
||||||
/* Handle some common WAV file malformations */
|
/* Handle some common WAV file malformations */
|
||||||
while (*p == '\0') {
|
while (*p == '\0' && off < len) {
|
||||||
p++;
|
p++;
|
||||||
off++;
|
off++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user