Fix rsg_generator.c to properly propagate NULL values.

This patch modifies rsg_generator.c to properly propagate NULL values in the
presence of inlined data pointers.

Change-Id: I5f91518807d4ab05148c9382e143581157409be6
diff --git a/rsg_generator.c b/rsg_generator.c
index be2dacc..75ea1a3 100644
--- a/rsg_generator.c
+++ b/rsg_generator.c
@@ -294,7 +294,9 @@
                 const VarType *vt = &api->params[ct2];
                 needFlush += vt->ptrLevel;
                 if (vt->ptrLevel && hasInlineDataPointers(api)) {
-                    fprintf(f, "    if (dataSize < io->getMaxInlineSize()) {\n");
+                    fprintf(f, "    if (%s_length == 0) {\n", vt->name);
+                    fprintf(f, "        cmd->%s = NULL;\n", vt->name);
+                    fprintf(f, "    } else if (dataSize < io->getMaxInlineSize()) {\n");
                     fprintf(f, "        memcpy(payload, %s, %s_length);\n", vt->name, vt->name);
                     fprintf(f, "        cmd->%s = (", vt->name);
                     printVarType(f, vt);
@@ -489,7 +491,8 @@
             needFlush += vt->ptrLevel;
 
             if (hasInlineDataPointers(api) && vt->ptrLevel) {
-                fprintf(f, ",\n           (const %s *)&baseData[(intptr_t)cmd->%s]", vt->typeName, vt->name);
+                fprintf(f, ",\n           cmd->%s_length == 0 ? NULL : (const %s *)&baseData[(intptr_t)cmd->%s]",
+                        vt->name, vt->typeName, vt->name);
             } else {
                 fprintf(f, ",\n           cmd->%s", vt->name);
             }