gluon-mesh-vpn-core: fix two more missing NULL checks
read_stdout can return NULL and thus the return value need to be checked prior to accessing it. Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
parent
7e1e9fe2bd
commit
344f8a47db
@ -110,6 +110,9 @@ static struct json_object * get_mesh_vpn_enabled() {
|
|||||||
int enabled = -1;
|
int enabled = -1;
|
||||||
char *line = read_stdout("exec lua -e 'print(require(\"gluon.mesh-vpn\").enabled())'");
|
char *line = read_stdout("exec lua -e 'print(require(\"gluon.mesh-vpn\").enabled())'");
|
||||||
|
|
||||||
|
if (!line)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (!strcmp(line, "true"))
|
if (!strcmp(line, "true"))
|
||||||
enabled = 1;
|
enabled = 1;
|
||||||
if (!strcmp(line, "false"))
|
if (!strcmp(line, "false"))
|
||||||
@ -126,7 +129,7 @@ static struct json_object * get_mesh_vpn_enabled() {
|
|||||||
static struct json_object * get_active_vpn_provider() {
|
static struct json_object * get_active_vpn_provider() {
|
||||||
char *line = read_stdout("exec lua -e 'name, _ = require(\"gluon.mesh-vpn\").get_active_provider(); print(name)'");
|
char *line = read_stdout("exec lua -e 'name, _ = require(\"gluon.mesh-vpn\").get_active_provider(); print(name)'");
|
||||||
|
|
||||||
if (!strcmp(line, "nil")) {
|
if (line && !strcmp(line, "nil")) {
|
||||||
free(line);
|
free(line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user