The Shift Around [Bug] Multiple Memory Safety
Urus markets itself as safer than C, but four memory flaws in urus_runtime.h expose real risks. Critical bugs include uninitialized lengths in str_replace, missing cleanup in pop(), unchecked malloc returns in read_file, and silent failures in ftell(). These flaws cause garbage data, crashes, and silent leaks - especially dangerous in long-running systems. POCs show 268MB of heap leak after 1000 pops and segfaults on low-memory runs. Fixes include safe allocation wrappers, proper NULL checks, and validating ftell() and fread. Understanding these vulnerabilities isnāt just technical - itās essential for building trust in systems that claim safety. How well do you guard against invisible memory flaws in modern code?nnnn### Whatās at Stake?nUrusā promise of āreference countingā and āimmutable by defaultā crumbles under scrutiny. When r->len remains uninitialized, string functions return garbage; when malloc fails and NULL isnāt checked, programs crash. Silent leaks grow fast: 176KB after 5,000 allocations. These arenāt just bugs - theyāre breaches of user confidence.nnnn### The Hidden Dangersn- Uninitialized len: str_replace() reads garbage instead of valid data.n- NULL deallocation: pop() frees elements without cleaning referenced objects, corrupting memory.n- Silent malloc failures: read_file() ignores ftell() errors and fread issues, producing corrupted strings.n- Unchecked ftell(): Returns -1 (especially on pipes or FIFOs), triggering crashes when used with malloc.nnnn### Why This Matters for Developers and UsersnEven āsafer than Cā code must defend against memory misuse. A single leak or crash can destabilize critical systems - from embedded devices to cloud services. Awareness turns vulnerability into prevention. Can your Rust or C runtime handle these hidden risks?nnnn### Final ThoughtnMemory safety isnāt a feature - itās a foundation. The Urus runtimeās flaws prove even well-intentioned designs fail without rigorous checks. As we build smarter systems, letās build them with defenses that outlast hype.ā