File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 11// Code for demangling Rust symbols. This code is mostly
22// a line-by-line translation of the Rust code in `rustc-demangle`.
33
4+ // you can find the latest version of this code in https://github.com/rust-lang/rustc-demangle
5+
46#include <stdint.h>
57#include <stddef.h>
68#include <string.h>
@@ -1707,10 +1709,8 @@ NODISCARD static demangle_status rust_demangle_legacy_demangle(const char *s, si
17071709 if (chars_len == 0 ) {
17081710 return DemangleInvalid ;
17091711 }
1710- char c = * chars ++ ;
1711- chars_len -- ;
1712-
1713- while (c != 'E' ) {
1712+ char c ;
1713+ while ((c = * chars ) != 'E' ) {
17141714 // Decode an identifier element's length
17151715 if (c < '0' || c > '9' ) {
17161716 return DemangleInvalid ;
@@ -1726,25 +1726,25 @@ NODISCARD static demangle_status rust_demangle_legacy_demangle(const char *s, si
17261726 return DemangleInvalid ;
17271727 }
17281728 len += d ;
1729+
1730+ chars ++ ;
1731+ chars_len -- ;
17291732 if (chars_len == 0 ) {
17301733 return DemangleInvalid ;
17311734 }
1732- c = * chars ++ ;
1733- chars_len -- ;
1735+ c = * chars ;
17341736 }
17351737
17361738 // Advance by the length
1737- for (size_t i = 0 ; i < len ; i ++ ) {
1738- if (chars_len == 0 ) {
1739- return DemangleInvalid ;
1740- }
1741- c = * chars ++ ;
1742- chars_len -- ;
1739+ if (chars_len <= len ) {
1740+ return DemangleInvalid ;
17431741 }
1742+ chars += len ;
1743+ chars_len -= len ;
17441744 elements ++ ;
17451745 }
17461746 * res = (struct demangle_legacy ) { inner , inner_len , elements };
1747- * rest = chars ;
1747+ * rest = chars + 1 ;
17481748 return DemangleOk ;
17491749}
17501750
You can’t perform that action at this time.
0 commit comments