diff --git a/reader/load_libs.c b/reader/load_libs.c index e200a2bac..31307401c 100755 --- a/reader/load_libs.c +++ b/reader/load_libs.c @@ -115,12 +115,12 @@ void setLibNames(LoadLibNames tmp) g_ldnames.chDocumentPr = NULL; } else { fprintf(stderr, "INFO: Copying library path: %s\n", tmp.chDocumentPr); - g_ldnames.chDocumentPr = (char*)malloc(strlen(tmp.chDocumentPr)+1); + size_t len = strlen(tmp.chDocumentPr) + 1; + g_ldnames.chDocumentPr = (char*)malloc(len); if (!g_ldnames.chDocumentPr) { fprintf(stderr, "ERROR: Failed to allocate memory for library path\n"); return; } - strcpy(g_ldnames.chDocumentPr,tmp.chDocumentPr); + memcpy(g_ldnames.chDocumentPr, tmp.chDocumentPr, len); } } -