Remove some strdup abuse.
[oweals/opkg-lede.git] / libopkg / conffile.c
index 519ba45fc037ab97a4acdfc79ab3d269357f7765..d74ee60ee45534210071bc6882cd39e386ccd1f3 100644 (file)
@@ -1,4 +1,4 @@
-/* conffile.c - the itsy package management system
+/* conffile.c - the opkg package management system
 
    Carl D. Worth
 
@@ -40,7 +40,7 @@ int conffile_has_been_modified(opkg_conf_t *conf, conffile_t *conffile)
     char *md5sum;
     char *filename = conffile->name;
     char *root_filename;
-    int ret;
+    int ret = 1;
 
     if (conffile->value == NULL) {
         opkg_message(conf, OPKG_NOTICE, "%s: conffile %s has no md5sum\n", __FUNCTION__, conffile->name);
@@ -51,14 +51,14 @@ int conffile_has_been_modified(opkg_conf_t *conf, conffile_t *conffile)
 
     md5sum = file_md5sum_alloc(root_filename);
 
-    ret = strcmp(md5sum, conffile->value);
-    if (ret) {
+    if (md5sum && (ret = strcmp(md5sum, conffile->value))) {
       opkg_message(conf, OPKG_NOTICE, "%s: conffile %s: \t\nold md5=%s \t\nnew md5=%s\n", __FUNCTION__,
               conffile->name, md5sum, conffile->value);
     }
 
     free(root_filename);
-    free(md5sum);
+    if (md5sum)
+        free(md5sum);
 
     return ret;
 }