Changeset 13486 in project


Ignore:
Timestamp:
03/04/09 05:30:38 (11 years ago)
Author:
Jim Ursetto
Message:

tokyocabinet: free() value even when too long for string

Location:
release/3/tokyocabinet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/tokyocabinet/tokyocabinet.scm

    r13476 r13486  
    3535
    3636;; tc-hdb-tune flags
     37(define-foreign-variable +max-string-length+ int "C_HEADER_SIZE_MASK")
    3738(define-foreign-variable HDBTLARGE int "HDBTLARGE")
    3839(define-foreign-variable HDBTDEFLATE int "HDBTDEFLATE")
     
    149150                    c-pointer scheme-pointer int (c-pointer int)))
    150151  (let-location ((size int))
    151     (let ((valptr (tchdbget hdb key
    152                             (string-length key) (location size))))
    153       (and valptr
    154            (let ((val (make-string size)))
    155              (##core#inline "copy_string_result" valptr size val)
    156              (free valptr)
    157              val)))))
     152    (and-let* ((valptr (tchdbget hdb key
     153                                 (string-length key) (location size))))
     154      ;; Exception handling imposes an unacceptable overhead.
     155      (when (fx> size +max-string-length+)
     156        (free valptr)
     157        (error 'tc-hdb-get "value length too long" size))
     158      (let ((val (make-string size)))
     159        (##core#inline "copy_string_result" valptr size val)
     160        (free valptr)
     161        val))))
    158162
    159163(define tc-hdb-iter-init
  • release/3/tokyocabinet/tokyocabinet.setup

    r13476 r13486  
    77 'tokyocabinet
    88 "tokyocabinet.so"
    9  '((version 1.01)
     9 '((version 1.02)
    1010   (exports "tokyocabinet.exports")))
Note: See TracChangeset for help on using the changeset viewer.