Alex Riesen <raa.lkml@xxxxxxxxx> writes: > 2009/4/29 Junio C Hamano <gitster@xxxxxxxxx>: >> + >> + if (S_ISGITLINK(mode)) { >> + blob = xmalloc(100); >> + *size = snprintf(blob, 100, >> + "Subproject commit %s\n", sha1_to_hex(sha1)); > > snprintf returns a signed value. It also has a bad record of returning > negative values for obscure reasons (on obscure platforms, admittedly). The arena is sufficiently large that there is no way any broken snprintf can return negative here. This is a copy from Linus's diff_populate_gitlink(), that dates back to 0478675 (Expose subprojects as special files to "git diff" machinery, 2007-04-15), and you have never seen any breakage, which should tell you something. As I mentioned in the original patch, the codepath that reads one side of diff (either from a blob or from a work tree entity) in show_patch_diff() and grab_blob() in combine-diff.c should do the same thing as what diff_populate_filespec() in diff.c does, and these three functions need some refactoring to share more code. The patch however is about fixing the existing breakage without invasive refactoring. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html