about summary refs log tree commit diff stats
path: root/108write.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-25 18:45:11 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-25 18:45:11 -0700
commita148b23a22709a45647fd07ce95db9147217a061 (patch)
treedb95e96fbb4a1da518f25bcda5cf863b34ecb4a1 /108write.subx
parent8a6ad45d8d26c60b62a2a7ac8d594b3c4d1dbc45 (diff)
downloadmu-a148b23a22709a45647fd07ce95db9147217a061.tar.gz
7101 - tile: remove quotes when evaluating strings
This found several bugs due to me not checking for null strings.
Diffstat (limited to '108write.subx')
-rw-r--r--108write.subx3
1 files changed, 3 insertions, 0 deletions
diff --git a/108write.subx b/108write.subx
index 988e21db..84060c62 100644
--- a/108write.subx
+++ b/108write.subx
@@ -25,6 +25,9 @@ write:  # f: fd or (addr stream byte), s: (addr array byte)
     # . prologue
     55/push-ebp
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
+    # if (s == 0) return
+    81          7/subop/compare     1/mod/*+disp8   5/rm32/ebp    .           .             .           .           0xc/disp8       0/imm32           # compare *(ebp+12)
+    74/jump-if-=  $write:end/disp8
     # if (f < 0x08000000) _write(f, s) and return  # f can't be a user-mode address, so treat it as a kernel file descriptor
     81          7/subop/compare     1/mod/*+disp8   5/rm32/ebp    .           .             .           .           8/disp8         0x08000000/imm32  # compare *(ebp+8)
     73/jump-if-addr>=  $write:fake/disp8