You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know what you mean by "strict code" or "stricting", but this looks like a memory leak of old value of 'z', that was allocated by mk() earlier. It is not in book's errata.
But I don't think the branch if (endp == p) here is ever taken. This is because called XP_fromstr() can return with that condition only if passed string contains zero valid digits in base. But AP_fromstr() validates the digits before calling XP_fromstr() and before z = mk(((k*n + 7)&~7)/8) call. However if this validation fails with first digit (the endp == p case), then n is 0 which makes entire expression 0 and mk() asserts on assert(size > 0) line:
Uncaught exception Assertion failed raised at src/ap.c:26
aborting...
This exception makes the error handling block dead code, and is bug in itself. Call char *end; AP_fromstr("A", 10, &end); to easily reproduce.
juniskane
added a commit
to juniskane/cii
that referenced
this issue
Mar 9, 2023
Calls where first character in string is not a valid digit
in base, like:
char *end;
AP_fromstr("A", 10, &end);
throw an unhandled exception:
Uncaught exception Assertion failed raised at src/ap.c:26
aborting...
instead of properly handling the error.
Issue described in drh#13
https://github.com/drh/cii/blob/master/src/ap.c#L361
Before
AP_new(0)
, callAP_free(&z)
making code stricting, Does it ?if (endp == p) { endp = (char *)str; z = AP_new(0); }
The text was updated successfully, but these errors were encountered: