Browse Source

win-capture: Improve reading from get-graphics-offsets

Increase the buffer size to read the response in one call if possible,
and cause an error condition with log message if the offsets string is
empty.
Richard Stanway 7 years ago
parent
commit
f48b210d61
1 changed files with 8 additions and 2 deletions
  1. 8 2
      plugins/win-capture/load-graphics-offsets.c

+ 8 - 2
plugins/win-capture/load-graphics-offsets.c

@@ -161,7 +161,7 @@ bool load_graphics_offsets(bool is32bit, const char *config_path)
 	struct dstr str = {0};
 	os_process_pipe_t *pp;
 	bool success = false;
-	char data[128];
+	char data[2048];
 
 #ifndef _WIN64
 	if (!is32bit && !is_64_bit_windows()) {
@@ -181,13 +181,19 @@ bool load_graphics_offsets(bool is32bit, const char *config_path)
 	}
 
 	for (;;) {
-		size_t len = os_process_pipe_read(pp, (uint8_t*)data, 128);
+		size_t len = os_process_pipe_read(pp, (uint8_t*)data, sizeof(data));
 		if (!len)
 			break;
 
 		dstr_ncat(&str, data, len);
 	}
 
+	if (dstr_is_empty(&str)) {
+		blog(LOG_INFO, "load_graphics_offsets: Failed to read "
+				"from '%s'", offset_exe.array);
+		goto error;
+	}
+
 	dstr_copy(&config_ini, config_path);
 	dstr_cat(&config_ini, is32bit ? "32.ini" : "64.ini");