Fix wrong size in xy_getcmd()

This commit is contained in:
Aoran Zeng 2023-09-27 12:46:47 +08:00
parent b5b32bcee8
commit 629e860ae9

4
xy.h
View File

@ -447,14 +447,14 @@ xy_getcmd(const char* cmd, bool (*func)(const char*))
FILE* stream = popen(cmd, "r");
if (stream == NULL) {
fprintf(stderr, "命令执行失败\n");
fprintf(stderr, "xy: 命令执行失败\n");
return NULL;
}
char* ret = NULL;
while (true) {
if(NULL==fgets(buf, sizeof(buf), stream)) break;
if(NULL==fgets(buf, size, stream)) break;
ret = buf;
if (func) { func(buf); }
}