[automerger skipped] tinycompress: Fix error handling in plugins. am: fc8976c893 am: 961c9afd6b am: b45e6a49fe -s ours

am skip reason: Change-Id I7ea6a7bb712367546607b8d7985cc4de8ca2455f with SHA-1 f86d1a2e03 is in history

Original change: https://android-review.googlesource.com/c/platform/external/tinycompress/+/1551055

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I565780238089c4d06121308e22aa75eb89aabd9d
diff --git a/compress_plugin.c b/compress_plugin.c
index 24d72ee..7a5538d 100644
--- a/compress_plugin.c
+++ b/compress_plugin.c
@@ -366,14 +366,15 @@
 		fprintf(stderr, "%s: invalid library name\n", __func__);
 		goto err_open_fn;
 	}
-	open_fn = calloc(1, strlen(name) + strlen("_open") + 1);
+	const size_t open_fn_size = strlen(name) + strlen("_open") + 1;
+	open_fn = calloc(1, open_fn_size);
 	if (!open_fn) {
 		rc = -ENOMEM;
 		goto err_open_fn;
 	}
 
-	strlcpy(open_fn, name, strlen(name) + 1);
-	strlcat(open_fn, "_open", strlen(name) + strlen("_open") + 1);
+	strlcpy(open_fn, name, open_fn_size);
+	strlcat(open_fn, "_open", open_fn_size);
 
 	plug_data->plugin_open_fn = dlsym(dl_hdl, open_fn);
 	if (!plug_data->plugin_open_fn) {