File: qa-nullstring

package info (click to toggle)
newlisp 10.7.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,292 kB
  • sloc: ansic: 33,280; lisp: 4,181; sh: 609; makefile: 215
file content (26 lines) | stat: -rwxr-xr-x 692 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env newlisp

; unpack, get-string and ffliob returns with char* == NULL
; should give an error message "ERR: cannot convert NULL to string"
; else they most likely will segfault

(struct '_struct_string "char*" "long")
(setf s (pack _struct_string 0 0))

(if (not (catch (unpack _struct_string s) 'ret))
        (println ">>>>> SUCCESS unpacking NULL ptr")
        (println ">>>>> ERROR unpacking NULL ptr")
)

(if (and 
        (not (catch (get-string 0) 'ret))
        (not (catch (get-string 0 10) 'ret))
        (not (catch (get-string 0 10 "end") 'ret))
    )
    (println ">>>>> SUCCESS get-string on NULL ptr")
    (println ">>>>> ERROR get-string on NULL ptr")
)

(exit)