]> git.meshlink.io Git - meshlink/blobdiff - src/conf.c
Fix a crash when meshlink_open() is called with an invalid confbase.
[meshlink] / src / conf.c
index a53db04604ed10bc8725053a38bb9d33edfb84b8..5231a9dfca25fc16c1a8fd3fbf63b9c0a8001081 100644 (file)
@@ -51,7 +51,8 @@ void init_configuration(splay_tree_t **config_tree) {
 }
 
 void exit_configuration(splay_tree_t **config_tree) {
-       splay_delete_tree(*config_tree);
+       if(*config_tree)
+               splay_delete_tree(*config_tree);
        *config_tree = NULL;
 }
 
@@ -323,10 +324,9 @@ bool append_config_file(meshlink_handle_t *mesh, const char *name, const char *k
        if(!fp) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Cannot open config file %s: %s", filename, strerror(errno));
        } else {
-               fprintf(fp, "\n# The following line was automatically added by tinc\n%s = %s\n", key, value);
+               fprintf(fp, "%s = %s\n", key, value);
                fclose(fp);
        }
 
-
        return fp != NULL;
 }