zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.72k stars 783 forks source link

Working #144

Closed sdasgup3 closed 5 years ago

sdasgup3 commented 6 years ago
pt300 commented 6 years ago

Four things for now:

  1. You're freeing variables just before the program exits. What's the point in that? You're not fixing any memory leak.
  2. You aren't supposed to cast void pointers.
  3. I kind of don't see the point of your example.
  4. Your example is vulnerable to the same out of bounds read as jsondump. See #125
sdasgup3 commented 6 years ago
  1. I am using the code as sub-part in another project.
  2. Agreed.
  3. Unlike other json library which provides API's to access Json objects, jsmn has a minimalist approach. I wrote some simple access-or functions like get_primitive to be combined to extract higher structure. I thought it might be useful to be in the examples directory. I can work out a better example.
pt300 commented 6 years ago

I'm not sure if you were trying to answer each of my point separately but anyway. Looking again at your example I think I kind of see what you are trying to do. I'm not really sure if that code really helps but these type checks could point people into right direction regarding input validation. At this point I still have mixed feelings about it. Regarding the code itself, beside the mistakes I already mentioned earlier (pointer casting, out of bounds read), your code has really erratic indentation which makes it hard to read. I'm not a maintainer but in it's current form I don't see this pull request getting accepted.