From 81b27fa224a8a2d48b6d1db9499ed3605a8b97af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 10 May 2016 18:43:48 +0200 Subject: [PATCH] Properly clear error flag after checking for entry location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/gammu/wammu/issues/23 Signed-off-by: Michal Čihař --- gammu/src/convertors/memory.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gammu/src/convertors/memory.c b/gammu/src/convertors/memory.c index 27d38a9ed..0b1d148d2 100644 --- a/gammu/src/convertors/memory.c +++ b/gammu/src/convertors/memory.c @@ -407,17 +407,18 @@ int MemoryEntryFromPython(PyObject * dict, GSM_MemoryEntry * entry, location = GetCharFromDict(item, "Location"); if (location == NULL) { - entry->Entries[i].Location = PBK_Location_Unknown; - } else { - if (strcmp(location, "Home") == 0) { - entry->Entries[i].Location = PBK_Location_Home; - } else if (strcmp(location, "Work") == 0) { - entry->Entries[i].Location = PBK_Location_Work; - } else { - entry->Entries[i].Location = PBK_Location_Unknown; - } - free(location); - } + PyErr_Clear(); + entry->Entries[i].Location = PBK_Location_Unknown; + } else { + if (strcmp(location, "Home") == 0) { + entry->Entries[i].Location = PBK_Location_Home; + } else if (strcmp(location, "Work") == 0) { + entry->Entries[i].Location = PBK_Location_Work; + } else { + entry->Entries[i].Location = PBK_Location_Unknown; + } + free(location); + } /* Zero everything, just to be sure */ entry->Entries[i].Text[0] = 0;