]> 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 aa22c47ff9a67807e2721ba7d7671a3bcbfe7a0e..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,6 +324,7 @@ 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, "%s = %s\n", key, value);
                fclose(fp);
        }