Menu

#9 Thread Safety Issue due to "ep"

open
nobody
None
5
2016-01-13
2013-04-17
asif
No

cJSON contains a static global "ep" pointer that could be a problem for threads safety. I am not sure whether the "thread safety" has been verified for cJSON, but "ep" is one potential problem.

To fix this, one way is to pass "ep" as parameter to the functions where it is being modified.

Discussion

  • asif

    asif - 2013-04-19

    cJSON.c patch

     
  • asif

    asif - 2013-04-19

    cJSON.h patch

     
  • Marcos Kirsch

    Marcos Kirsch - 2016-01-13

    In order to maintain source compatibility, new thread safe flavors for each of the functions that touch ep would need to be introduced with the extra parameter. Or some macro magic to make it client-selectable.

    I think making cJSON thread safe in 2016 should be high priority.

     

    Last edit: Marcos Kirsch 2016-01-13

Log in to post a comment.