[Forensics-changes] [yara] 172/415: Fix error handling issues
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:43:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 1a242f54a4d0e39809f8e5c4b2e8b14fa13ec598
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Fri May 31 11:20:24 2013 +0000
Fix error handling issues
---
libyara/ahocorasick.c | 6 ++++++
yara-python/yara-python.c | 10 +++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/libyara/ahocorasick.c b/libyara/ahocorasick.c
index 05e1ee5..f092287 100644
--- a/libyara/ahocorasick.c
+++ b/libyara/ahocorasick.c
@@ -711,6 +711,9 @@ int yr_ac_create_automaton(
offsetof(AC_AUTOMATON, root),
EOL);
+ if (result != ERROR_SUCCESS)
+ return result;
+
result = yr_arena_allocate_struct(
arena,
sizeof(AC_STATE),
@@ -719,6 +722,9 @@ int yr_ac_create_automaton(
offsetof(AC_STATE, matches),
EOL);
+ if (result != ERROR_SUCCESS)
+ return result;
+
(*automaton)->root = root_state;
root_state->depth = 0;
diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index 9853aee..a1d241c 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -574,9 +574,7 @@ PyObject* handle_error(
YaraError,
"access denied");
case ERROR_INSUFICIENT_MEMORY:
- return PyErr_Format(
- YaraError,
- "not enough memory");
+ return PyErr_NoMemory();
case ERROR_COULD_NOT_OPEN_FILE:
return PyErr_Format(
YaraError,
@@ -975,8 +973,10 @@ static PyObject * yara_compile(
&includes,
&externals))
{
- if (yr_compiler_create(&compiler) != ERROR_SUCCESS)
- return PyErr_NoMemory();
+ error = yr_compiler_create(&compiler);
+
+ if (error != ERROR_SUCCESS)
+ return handle_error(error, NULL);
if (includes != NULL)
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list