builtin/branch.c: use error_errno()
[gitweb.git] / builtin / apply.c
index d61ac65dab28a766a13782bdef572431e20e80ff..42c610e2ec180e789fdae4bc637dd96f533d1e10 100644 (file)
@@ -2632,7 +2632,7 @@ static void update_image(struct image *img,
        insert_count = postimage->len;
 
        /* Adjust the contents */
-       result = xmalloc(img->len + insert_count - remove_count + 1);
+       result = xmalloc(st_add3(st_sub(img->len, remove_count), insert_count, 1));
        memcpy(result, img->buf, applied_at);
        memcpy(result + applied_at, postimage->buf, postimage->len);
        memcpy(result + applied_at + postimage->len,