aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/python
diff options
context:
space:
mode:
authorGravatar Andrew Selle <aselle@google.com>2018-08-10 11:51:36 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-10 12:05:08 -0700
commitd2bec062040bfa083195c06deef56981c6f0f946 (patch)
treed8d4430a5ccbc0237937127e678df5c3081089a9 /tensorflow/contrib/lite/python
parent1cd9c422e673220087319644e72589a0a3476cfc (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.py4
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))