#Allocation size does not match free

1 messages · Page 1 of 1 (latest)

hazy forum
#

Hey guys, I've been struggling with the following error message for some time now:

 error(gpa): Allocation size 27 bytes does not match free size 26. Allocation: 
/home/nikolay.hadzhiev/.zvm/master/lib/std/mem/Allocator.zig:456:40: 0x1197717 in dupeZ__anon_24509 (std.zig)
    const new_buf = try allocator.alloc(T, m.len + 1);
                                       ^
/home/nikolay.hadzhiev/Schreibtisch/sisyphus/src/Helper.zig:6:32: 0x118e7a1 in toRaylib (main.zig)
    const rlStr = try gpa.dupeZ(u8, cstr);
                               ^
/home/nikolay.hadzhiev/Schreibtisch/sisyphus/src/Rendering/StatisticsRenderer.zig:97:38: 0x1190193 in createStatistic__anon_24695 (main.zig)
    const rlStr = try Helper.toRaylib(&str, gpa);
                                     ^
/home/nikolay.hadzhiev/Schreibtisch/sisyphus/src/Rendering/StatisticsRenderer.zig:38:50: 0x119180d in render (main.zig)
    const prevSlipChanceStr = try createStatistic(gpa, @TypeOf(prevSlipChance), prevSlipChance, "Previous Slip Chance: ");
                                                 ^

...
 Free: 
/home/nikolay.hadzhiev/Schreibtisch/sisyphus/src/Rendering/StatisticsRenderer.zig:39:19: 0x11949df in render (main.zig)
    defer gpa.free(prevSlipChanceStr);

All relevant code here: https://zigbin.io/e66106

jolly root
#

createStatistic returns []const u8 which doesn't include the sentinel so it's not freed properly

marsh marten
#

^^ the size is 1 larger due to the sentinel, that information is lost when it coerces to the non terminated slice