Commit f930a23
utf8: refactor
In `strbuf_utf8_replace`, we preallocate the destination buffer and then
use `memcpy` to copy bytes into it at computed offsets. This feels
rather fragile and is hard to understand at times. Refactor the code to
instead use `strbuf_add` and `strbuf_addstr` so that we can be sure that
there is no possibility to perform an out-of-bounds write.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>strbuf_utf8_replace to not rely on preallocated buffer1 parent 81c2d4c commit f930a23
1 file changed
+13
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
373 | 371 | | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
| 372 | + | |
378 | 373 | | |
379 | 374 | | |
| 375 | + | |
380 | 376 | | |
381 | | - | |
382 | 377 | | |
383 | 378 | | |
384 | 379 | | |
385 | | - | |
| 380 | + | |
386 | 381 | | |
387 | | - | |
388 | 382 | | |
389 | 383 | | |
390 | 384 | | |
| |||
404 | 398 | | |
405 | 399 | | |
406 | 400 | | |
407 | | - | |
408 | | - | |
| 401 | + | |
409 | 402 | | |
410 | 403 | | |
411 | | - | |
412 | | - | |
| 404 | + | |
| 405 | + | |
413 | 406 | | |
414 | | - | |
415 | | - | |
| 407 | + | |
416 | 408 | | |
417 | 409 | | |
418 | | - | |
419 | | - | |
| 410 | + | |
| 411 | + | |
420 | 412 | | |
421 | | - | |
| 413 | + | |
422 | 414 | | |
423 | 415 | | |
424 | 416 | | |
| |||
0 commit comments