$OpenBSD: patch-rcsparse_c,v 1.1 2013/05/15 20:17:54 dcoppa Exp $
Free the fulltext of unmatched revisions while searching for the
requested revision to avoid exhausting all available memory during
the search.
See: https://github.com/ustuehler/git-cvs/commit/b9fb06697901177ffff554ce692bf829ed6b6b79
old
|
new
|
rcscheckout(struct rcsfile *rcs, const char *revstr, s |
937 | 937 | { |
938 | 938 | struct rcsrev searchrev; |
939 | 939 | struct rcstoken searchtok; |
940 | | struct rcsrev *currcsrev; |
| 940 | struct rcsrev *currcsrev, *curtextrev; |
941 | 941 | struct stringinfo *curtext; |
942 | 942 | struct rcstoken *nextrev; |
943 | 943 | char *branchrev, *tmpstr; |
… |
… |
rcscheckout(struct rcsfile *rcs, const char *revstr, s |
946 | 946 | if (rcsparsetree(rcs) < 0) |
947 | 947 | return NULL; |
948 | 948 | |
| 949 | curtextrev = NULL; |
949 | 950 | curtext = NULL; |
950 | 951 | nextrev = NULL; |
951 | 952 | branchrev = NULL; |
… |
… |
rcscheckout(struct rcsfile *rcs, const char *revstr, s |
986 | 987 | |
987 | 988 | if (curtext == NULL) { |
988 | 989 | curtext = currcsrev->rawtext; |
| 990 | curtextrev = currcsrev; |
989 | 991 | } else { |
990 | 992 | if (nextrev == NULL) |
991 | 993 | goto fail; |
… |
… |
rcscheckout(struct rcsfile *rcs, const char *revstr, s |
995 | 997 | |
996 | 998 | if (currcsrev->text) { |
997 | 999 | /* Was expanded before */ |
| 1000 | if (curtextrev != NULL) { |
| 1001 | free(curtextrev->text); |
| 1002 | curtextrev->text = NULL; |
| 1003 | } |
998 | 1004 | curtext = currcsrev->text; |
| 1005 | curtextrev = currcsrev; |
999 | 1006 | } else { |
1000 | 1007 | if (currcsrev->rawtext == NULL) |
1001 | 1008 | goto fail; |
… |
… |
rcscheckout(struct rcsfile *rcs, const char *revstr, s |
1004 | 1011 | goto fail; |
1005 | 1012 | if (applydelta(&currcsrev->text, currcsrev->rawtext) < 0) |
1006 | 1013 | goto fail; |
1007 | | free(currcsrev->rawtext); |
1008 | | currcsrev->rawtext = NULL; |
| 1014 | if (curtextrev != NULL) { |
| 1015 | free(curtextrev->text); |
| 1016 | curtextrev->text = NULL; |
| 1017 | } |
1009 | 1018 | curtext = currcsrev->text; |
| 1019 | curtextrev = currcsrev; |
1010 | 1020 | } |
1011 | 1021 | } |
1012 | 1022 | |