Commit 432b2636d537f3e6f789ecc5bc6899266c625d78

Con Kolivas 2012-11-01T15:41:32

Check for invalid json result in work_decode.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/cgminer.c b/cgminer.c
index b1dc39f..8464c07 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1387,6 +1387,11 @@ static bool work_decode(struct pool *pool, struct work *work, json_t *val)
 	json_t *res_val = json_object_get(val, "result");
 	bool ret = false;
 
+	if (!res_val || json_is_null(res_val)) {
+		applog(LOG_ERR, "JSON Failed to decode result");
+		goto out;
+	}
+
 	if (pool->has_gbt) {
 		work->gbt = true;
 		goto out;