← Back to team overview

kicad-developers team mailing list archive

[PATCH] Handle empty string in cvpcb GetModuleInfo()

 

Hi,

Here is a tiny patch to defend against asserts in debug mode when the
footprint list in cvpcb is empty. The aFootprintName was coming in as
"" in that case.

You could also check for an empty string at the call sites, but since
this function already can return null (and thus callers should be ready
for that), it think it makes sense to do it in here?

Thanks,

John
diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp
index 99dde1c..382e141 100644
--- a/common/footprint_info.cpp
+++ b/common/footprint_info.cpp
@@ -275,6 +275,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* a
 
 FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
 {
+    if( aFootprintName.IsEmpty() )
+        return NULL;
+
     BOOST_FOREACH( FOOTPRINT_INFO& fp, m_list )
     {
         FPID fpid;

Follow ups