commit - 62ad13c507a97d98899383907ff33c526073e287
commit + f1cbc3bc64f9e253d5c1239d55b3179e6fd215c4
blob - a8e56d3ae101b242e7f90d82f2276a5ab517a4fb
blob + a74eaa79aa8bbba7182e603f859139548a3255cc
--- lib/object.c
+++ lib/object.c
break;
buf = got_object_blob_get_read_buf(blob);
i = hdrlen;
- if (line_offsets && nlines) {
- if (*line_offsets == NULL) {
+ if (nlines) {
+ if (line_offsets && *line_offsets == NULL) {
/* Have some data but perhaps no '\n'. */
noffsets = 1;
*nlines = 1;
continue;
}
(*nlines)++;
- if (noffsets < *nlines) {
+ if (line_offsets && noffsets < *nlines) {
off_t *o = recallocarray(*line_offsets,
noffsets, *nlines,
sizeof(**line_offsets));
*line_offsets = o;
noffsets = *nlines;
}
- off = total_len + i - hdrlen + 1;
- (*line_offsets)[*nlines - 1] = off;
+ if (line_offsets) {
+ off = total_len + i - hdrlen + 1;
+ (*line_offsets)[*nlines - 1] = off;
+ }
i++;
}
}