镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 08:52:45 +08:00
fix(upgrade): copy best version to a stable buffer before json_free
The latest-version pointer from json_str() dangles after json_free(root), so pmm upgrade printed garbage for the target version. Copy it into a local buf before freeing the JSON tree (now shows e.g. 'pureftpd 1.0.51 is up to date (latest 1.0.51)').
这个提交包含在:
+6
-2
@@ -366,12 +366,16 @@ static int cmd_upgrade(int argc, char **argv) {
|
|||||||
} else {
|
} else {
|
||||||
best = json_str(root, "version");
|
best = json_str(root, "version");
|
||||||
}
|
}
|
||||||
|
/* Copy best into a stable buffer BEFORE freeing the JSON tree: best
|
||||||
|
* currently points into json_str()'s internal storage. */
|
||||||
|
char bestbuf[128];
|
||||||
|
if (best) snprintf(bestbuf, sizeof(bestbuf), "%s", best);
|
||||||
json_free(root);
|
json_free(root);
|
||||||
if (!best) continue;
|
if (!best) continue;
|
||||||
|
|
||||||
if (cmp_version(best, curver) <= 0) { pmm_info("%s %s is up to date (latest %s)\n", pkg, curver, best); continue; }
|
if (cmp_version(bestbuf, curver) <= 0) { pmm_info("%s %s is up to date (latest %s)\n", pkg, curver, bestbuf); continue; }
|
||||||
|
|
||||||
pmm_info("%s: %s -> %s\n", pkg, curver, best);
|
pmm_info("%s: %s -> %s\n", pkg, curver, bestbuf);
|
||||||
if (!yes) {
|
if (!yes) {
|
||||||
printf(" upgrade? [y/N] ");
|
printf(" upgrade? [y/N] ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户