modelica-3rdparty / msgpack-modelica

A MessagePack implementation as a Modelica package
BSD 2-Clause "Simplified" License
6 stars 4 forks source link

Potential access violation #8

Closed tbeu closed 10 years ago

tbeu commented 10 years ago

In msgpack_modelica_stream_get

  res = ModelicaAllocateStringWithErrorReturn(st->size);
  memcpy(res,st->str,st->size);
  free(st->str);
  if (!res) {
    ModelicaError("Failed to allocate memory for stream\n");
  }

res should be checked immediately after alloc not after memcpy.