http: fix segfault in handle_curl_result

When we create an http active_request_slot, we can set its
"results" pointer back to local storage. The http code will
fill in the details of how the request went, and we can
access those details even after the slot has been cleaned
up.

Commit 8809703 (http: factor out http error code handling)
switched us from accessing our local results struct directly
to accessing it via the "results" pointer of the slot. That
means we're accessing the slot after it has been marked as
finished, defeating the whole purpose of keeping the results
storage separate.

Most of the time this doesn't matter, as finishing the slot
does not actually clean up the pointer. However, when using
curl's multi interface with the dumb-http revision walker,
we might actually start a new request before handing control
back to the original caller. In that case, we may reuse the
slot, zeroing its results pointer, and leading the original
caller to segfault while looking for its results inside the
slot.

Instead, we need to pass a pointer to our local results
storage to the handle_curl_result function, rather than
relying on the pointer in the slot struct. This matches what
the original code did before the refactoring (which did not
use a separate function, and therefore just accessed the
results struct directly).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 files changed
tree: f62cb81f35c64e98c71caa596a0cd0eebccb8f2d
  1. .gitattributes
  2. .gitignore
  3. .mailmap
  4. COPYING
  5. Documentation/
  6. GIT-VERSION-GEN
  7. INSTALL
  8. LGPL-2.1
  9. Makefile
  10. README
  11. abspath.c
  12. aclocal.m4
  13. advice.c
  14. advice.h
  15. alias.c
  16. alloc.c
  17. archive-tar.c
  18. archive-zip.c
  19. archive.c
  20. archive.h
  21. argv-array.c
  22. argv-array.h
  23. attr.c
  24. attr.h
  25. base85.c
  26. bisect.c
  27. bisect.h
  28. blob.c
  29. blob.h
  30. block-sha1/
  31. branch.c
  32. branch.h
  33. builtin.h
  34. builtin/
  35. bulk-checkin.c
  36. bulk-checkin.h
  37. bundle.c
  38. bundle.h
  39. cache-tree.c
  40. cache-tree.h
  41. cache.h
  42. check-builtins.sh
  43. check-racy.c
  44. check_bindir
  45. color.c
  46. color.h
  47. combine-diff.c
  48. command-list.txt
  49. commit.c
  50. commit.h
  51. compat/
  52. config.c
  53. config.mak.in
  54. configure.ac
  55. connect.c
  56. connected.c
  57. connected.h
  58. contrib/
  59. convert.c
  60. convert.h
  61. copy.c
  62. credential-cache--daemon.c
  63. credential-cache.c
  64. credential-store.c
  65. credential.c
  66. credential.h
  67. csum-file.c
  68. csum-file.h
  69. ctype.c
  70. daemon.c
  71. date.c
  72. decorate.c
  73. decorate.h
  74. delta.h
  75. diff-delta.c
  76. diff-lib.c
  77. diff-no-index.c
  78. diff.c
  79. diff.h
  80. diffcore-break.c
  81. diffcore-delta.c
  82. diffcore-order.c
  83. diffcore-pickaxe.c
  84. diffcore-rename.c
  85. diffcore.h
  86. dir.c
  87. dir.h
  88. editor.c
  89. entry.c
  90. environment.c
  91. exec_cmd.c
  92. exec_cmd.h
  93. fast-import.c
  94. fetch-pack.h
  95. fixup-builtins
  96. fmt-merge-msg.h
  97. fsck.c
  98. fsck.h
  99. generate-cmdlist.sh
  100. gettext.c
  101. gettext.h
  102. git-add--interactive.perl
  103. git-am.sh
  104. git-archimport.perl
  105. git-bisect.sh
  106. git-compat-util.h
  107. git-cvsexportcommit.perl
  108. git-cvsimport.perl
  109. git-cvsserver.perl
  110. git-difftool--helper.sh
  111. git-difftool.perl
  112. git-filter-branch.sh
  113. git-gui/
  114. git-instaweb.sh
  115. git-lost-found.sh
  116. git-merge-octopus.sh
  117. git-merge-one-file.sh
  118. git-merge-resolve.sh
  119. git-mergetool--lib.sh
  120. git-mergetool.sh
  121. git-parse-remote.sh
  122. git-pull.sh
  123. git-quiltimport.sh
  124. git-rebase--am.sh
  125. git-rebase--interactive.sh
  126. git-rebase--merge.sh
  127. git-rebase.sh
  128. git-relink.perl
  129. git-remote-testgit.py
  130. git-repack.sh
  131. git-request-pull.sh
  132. git-send-email.perl
  133. git-sh-i18n.sh
  134. git-sh-setup.sh
  135. git-stash.sh
  136. git-submodule.sh
  137. git-svn.perl
  138. git-web--browse.sh
  139. git.c
  140. git.spec.in
  141. git_remote_helpers/
  142. gitk-git/
  143. gitweb/
  144. gpg-interface.c
  145. gpg-interface.h
  146. graph.c
  147. graph.h
  148. grep.c
  149. grep.h
  150. hash.c
  151. hash.h
  152. help.c
  153. help.h
  154. hex.c
  155. http-backend.c
  156. http-fetch.c
  157. http-push.c
  158. http-walker.c
  159. http.c
  160. http.h
  161. ident.c
  162. imap-send.c
  163. kwset.c
  164. kwset.h
  165. levenshtein.c
  166. levenshtein.h
  167. list-objects.c
  168. list-objects.h
  169. ll-merge.c
  170. ll-merge.h
  171. lockfile.c
  172. log-tree.c
  173. log-tree.h
  174. mailmap.c
  175. mailmap.h
  176. match-trees.c
  177. merge-file.c
  178. merge-file.h
  179. merge-recursive.c
  180. merge-recursive.h
  181. mergetools/
  182. name-hash.c
  183. notes-cache.c
  184. notes-cache.h
  185. notes-merge.c
  186. notes-merge.h
  187. notes.c
  188. notes.h
  189. object.c
  190. object.h
  191. pack-check.c
  192. pack-refs.c
  193. pack-refs.h
  194. pack-revindex.c
  195. pack-revindex.h
  196. pack-write.c
  197. pack.h
  198. pager.c
  199. parse-options-cb.c
  200. parse-options.c
  201. parse-options.h
  202. patch-delta.c
  203. patch-ids.c
  204. patch-ids.h
  205. path.c
  206. perl/
  207. pkt-line.c
  208. pkt-line.h
  209. po/
  210. ppc/
  211. preload-index.c
  212. pretty.c
  213. progress.c
  214. progress.h
  215. prompt.c
  216. prompt.h
  217. quote.c
  218. quote.h
  219. reachable.c
  220. reachable.h
  221. read-cache.c
  222. reflog-walk.c
  223. reflog-walk.h
  224. refs.c
  225. refs.h
  226. remote-curl.c
  227. remote.c
  228. remote.h
  229. replace_object.c
  230. rerere.c
  231. rerere.h
  232. resolve-undo.c
  233. resolve-undo.h
  234. revision.c
  235. revision.h
  236. run-command.c
  237. run-command.h
  238. send-pack.h
  239. sequencer.c
  240. sequencer.h
  241. server-info.c
  242. setup.c
  243. sh-i18n--envsubst.c
  244. sha1-array.c
  245. sha1-array.h
  246. sha1-lookup.c
  247. sha1-lookup.h
  248. sha1_file.c
  249. sha1_name.c
  250. shallow.c
  251. shell.c
  252. shortlog.h
  253. show-index.c
  254. sideband.c
  255. sideband.h
  256. sigchain.c
  257. sigchain.h
  258. strbuf.c
  259. strbuf.h
  260. streaming.c
  261. streaming.h
  262. string-list.c
  263. string-list.h
  264. submodule.c
  265. submodule.h
  266. symlinks.c
  267. t/
  268. tag.c
  269. tag.h
  270. tar.h
  271. templates/
  272. test-chmtime.c
  273. test-credential.c
  274. test-ctype.c
  275. test-date.c
  276. test-delta.c
  277. test-dump-cache-tree.c
  278. test-genrandom.c
  279. test-index-version.c
  280. test-line-buffer.c
  281. test-match-trees.c
  282. test-mktemp.c
  283. test-parse-options.c
  284. test-path-utils.c
  285. test-run-command.c
  286. test-scrap-cache-tree.c
  287. test-sha1.c
  288. test-sha1.sh
  289. test-sigchain.c
  290. test-subprocess.c
  291. test-svn-fe.c
  292. thread-utils.c
  293. thread-utils.h
  294. trace.c
  295. transport-helper.c
  296. transport.c
  297. transport.h
  298. tree-diff.c
  299. tree-walk.c
  300. tree-walk.h
  301. tree.c
  302. tree.h
  303. unimplemented.sh
  304. unix-socket.c
  305. unix-socket.h
  306. unpack-trees.c
  307. unpack-trees.h
  308. upload-pack.c
  309. url.c
  310. url.h
  311. usage.c
  312. userdiff.c
  313. userdiff.h
  314. utf8.c
  315. utf8.h
  316. vcs-svn/
  317. walker.c
  318. walker.h
  319. wrap-for-bin.sh
  320. wrapper.c
  321. write_or_die.c
  322. ws.c
  323. wt-status.c
  324. wt-status.h
  325. xdiff-interface.c
  326. xdiff-interface.h
  327. xdiff/
  328. zlib.c