diff options
author | 2018-08-10 11:51:36 -0700 | |
---|---|---|
committer | 2018-08-10 12:05:08 -0700 | |
commit | d2bec062040bfa083195c06deef56981c6f0f946 (patch) | |
tree | d8d4430a5ccbc0237937127e678df5c3081089a9 /tensorflow/contrib/lite/python | |
parent | 1cd9c422e673220087319644e72589a0a3476cfc (diff) |
Fix crash where model_path input to tflite python interpreter segv.
Fix by holding reference to passed in model_content and relying on
immutability of PyString (pointer doesn't change).
PiperOrigin-RevId: 208244957
Diffstat (limited to 'tensorflow/contrib/lite/python')
-rw-r--r-- | tensorflow/contrib/lite/python/interpreter.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/python/interpreter.py b/tensorflow/contrib/lite/python/interpreter.py index 3243bddac8..1be61fe053 100644 --- a/tensorflow/contrib/lite/python/interpreter.py +++ b/tensorflow/contrib/lite/python/interpreter.py @@ -54,6 +54,10 @@ class Interpreter(object): if not self._interpreter: raise ValueError('Failed to open {}'.format(model_path)) elif model_content and not model_path: + # Take a reference, so the pointer remains valid. + # Since python strings are immutable then PyString_XX functions + # will always return the same pointer. + self._model_content = model_content self._interpreter = ( _interpreter_wrapper.InterpreterWrapper_CreateWrapperCPPFromBuffer( model_content)) |