Commit 7302c8f1 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

trivial: shell: return 0 if fromdec/hex is passd null

This was actually working anyways, because NULL pointers don't trap,
and the pointed-to char is currently 0x98, not a digit.

But I prefer to fix it before we do one of the following:
  - move to a new cpu that traps on null
  - use RAM at a different address than zeero
  - use "mvi r0, 0" instead of "xor r0,r0,r0" (would parse as 4).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c04fb597
......@@ -216,7 +216,7 @@ const char *fromhex(const char *hex, int *v)
{
int o = 0;
for (; *hex; ++hex) {
for (; hex && *hex; ++hex) {
if (*hex >= '0' && *hex <= '9') {
o = (o << 4) + (*hex - '0');
} else if (*hex >= 'A' && *hex <= 'F') {
......@@ -236,7 +236,7 @@ const char *fromdec(const char *dec, int *v)
{
int o = 0;
for (; *dec; ++dec) {
for (; dec && *dec; ++dec) {
if (*dec >= '0' && *dec <= '9') {
o = (o * 10) + (*dec - '0');
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment