From ff3392b9c9471cd6d837a9ab3abe135ab2d75edf Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 22 Oct 2010 17:25:15 +0200 Subject: introduce and use xmalloc_fgets/fgetline This fixes problems of having long lines truncated - and we do have very long lines sometimes - curl errors with HTML, list of debuginfos etc. Signed-off-by: Denys Vlasenko --- lib/plugins/CCpp.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'lib/plugins/CCpp.cpp') diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp index 642d97e9..ed5ab3b6 100644 --- a/lib/plugins/CCpp.cpp +++ b/lib/plugins/CCpp.cpp @@ -154,21 +154,14 @@ static char *install_debug_infos(const char *pDebugDumpDir, const char *debuginf return NULL; } - /* With 126 debuginfos I've seen lines 9k+ chars long... - * yet, having it truly unlimited is bad too, - * therefore we are using LARGE, but still limited buffer. - */ - char *buff = (char*) xmalloc(64*1024); - + char *buff; struct strbuf *buf_build_ids = strbuf_new(); - - while (fgets(buff, 64*1024, pipeout_fp)) + while ((buff = xmalloc_fgetline(pipeout_fp)) != NULL) { - strchrnul(buff, '\n')[0] = '\0'; - if (strncmp(buff, "MISSING:", 8) == 0) { strbuf_append_strf(buf_build_ids, "Debuginfo absent: %s\n", buff + 8); + free(buff); continue; } @@ -183,8 +176,8 @@ static char *install_debug_infos(const char *pDebugDumpDir, const char *debuginf VERB1 log("%s", buff); update_client("%s", buff); } + free(buff); } - free(buff); fclose(pipeout_fp); int status = 0; -- cgit