Index: cdr/cdr_sqlite3_custom.c =================================================================== --- cdr/cdr_sqlite3_custom.c (revision 137900) +++ cdr/cdr_sqlite3_custom.c (working copy) @@ -75,7 +75,7 @@ static int load_column_config(const char *tmp) { char *col = NULL; - char *cols = NULL; + char *cols = NULL, *colsinit; char *escaped = NULL; struct ast_str *column_string = NULL; @@ -92,13 +92,14 @@ ast_free(column_string); return -1; } + colsinit = cols; while ((col = strsep(&cols, ","))) { col = ast_strip(col); escaped = sqlite3_mprintf("%q", col); if (!escaped) { ast_log(LOG_ERROR, "Out of memory creating entry for column '%s' in table '%s.'\n", col, table); ast_free(column_string); - ast_free(cols); + ast_free(colsinit); return -1; } if (!column_string->used) @@ -110,11 +111,11 @@ if (!(columns = ast_strdup(column_string->str))) { ast_log(LOG_ERROR, "Out of memory copying columns string for table '%s.'\n", table); ast_free(column_string); - ast_free(cols); + ast_free(colsinit); return -1; } ast_free(column_string); - ast_free(cols); + ast_free(colsinit); return 0; } @@ -122,7 +123,7 @@ static int load_values_config(const char *tmp) { char *val = NULL; - char *vals = NULL; + char *vals = NULL, *valsinit; struct values *value = NULL; if (ast_strlen_zero(tmp)) { @@ -133,20 +134,21 @@ ast_log(LOG_ERROR, "Out of memory creating temporary buffer for value '%s'\n", tmp); return -1; } + valsinit = vals; while ((val = strsep(&vals, ","))) { /* Strip the single quotes off if they are there */ val = ast_strip_quoted(val, "'", "'"); value = ast_calloc(sizeof(char), sizeof(*value) + strlen(val) + 1); if (!value) { ast_log(LOG_ERROR, "Out of memory creating entry for value '%s'\n", val); - ast_free(vals); + ast_free(valsinit); return -1; } value->expression = (char *) value + sizeof(*value); ast_copy_string(value->expression, val, strlen(val) + 1); AST_LIST_INSERT_TAIL(&sql_values, value, list); } - ast_free(vals); + ast_free(valsinit); return 0; }