opkg: fix nullpointer dereference
[oweals/opkg-lede.git] / libopkg / opkg_cmd.c
index 99ee64d..d9ad77a 100644 (file)
@@ -951,7 +951,7 @@ static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv)
                    pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name );
                }
         
                    pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name );
                }
         
-               if (pkg == NULL) {
+               if (pkg_to_remove == NULL) {
                    opkg_message(conf, OPKG_ERROR, "Package %s is not installed.\n", pkg->name);
                    continue;
                }
                    opkg_message(conf, OPKG_ERROR, "Package %s is not installed.\n", pkg->name);
                    continue;
                }