pack-objects: Fix segfault when object count is less than thread count
[gitweb.git] / transport.c
index 4e151a9e878b402fd0b70c31057b9bcfcff7d9b7..babaa21398522939076151f1c240a4f18f9a90a1 100644 (file)
@@ -118,7 +118,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
                if (hexval(buffer[0]) > 0xf)
                        continue;
                len = strlen(buffer);
-               if (buffer[len - 1] == '\n')
+               if (len && buffer[len - 1] == '\n')
                        buffer[--len] = '\0';
                if (len < 41)
                        continue;