File tree 1 file changed +13
-13
lines changed
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 1
1
// Code for demangling Rust symbols. This code is mostly
2
2
// a line-by-line translation of the Rust code in `rustc-demangle`.
3
3
4
+ // you can find the latest version of this code in https://github.com/rust-lang/rustc-demangle
5
+
4
6
#include <stdint.h>
5
7
#include <stddef.h>
6
8
#include <string.h>
@@ -1707,10 +1709,8 @@ NODISCARD static demangle_status rust_demangle_legacy_demangle(const char *s, si
1707
1709
if (chars_len == 0 ) {
1708
1710
return DemangleInvalid ;
1709
1711
}
1710
- char c = * chars ++ ;
1711
- chars_len -- ;
1712
-
1713
- while (c != 'E' ) {
1712
+ char c ;
1713
+ while ((c = * chars ) != 'E' ) {
1714
1714
// Decode an identifier element's length
1715
1715
if (c < '0' || c > '9' ) {
1716
1716
return DemangleInvalid ;
@@ -1726,25 +1726,25 @@ NODISCARD static demangle_status rust_demangle_legacy_demangle(const char *s, si
1726
1726
return DemangleInvalid ;
1727
1727
}
1728
1728
len += d ;
1729
+
1730
+ chars ++ ;
1731
+ chars_len -- ;
1729
1732
if (chars_len == 0 ) {
1730
1733
return DemangleInvalid ;
1731
1734
}
1732
- c = * chars ++ ;
1733
- chars_len -- ;
1735
+ c = * chars ;
1734
1736
}
1735
1737
1736
1738
// 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 ;
1743
1741
}
1742
+ chars += len ;
1743
+ chars_len -= len ;
1744
1744
elements ++ ;
1745
1745
}
1746
1746
* res = (struct demangle_legacy ) { inner , inner_len , elements };
1747
- * rest = chars ;
1747
+ * rest = chars + 1 ;
1748
1748
return DemangleOk ;
1749
1749
}
1750
1750
You can’t perform that action at this time.
0 commit comments