← Back to context

Comment by wruza

4 years ago

Ok, let’s assume that 10mb json source was loaded into a not null-terminated opaque struct str_t {size_t; pchar;}. You have to parse a number from a position `i’ and you have (double parse_number(str_t)). Next obvious step?

You can keep the existing sscanf function and now strlen is O(1) so the bug is gone. Any questions?

  • I just can’t figure out the exact code.

    • I think your code would be pretty much the same, sscanf, strlen and all. The main differences would be the standard library's implementations of strlen and whatever function you use to read the file into a string in the first place.

      8 replies →